-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-unnecessary-boolean-literal-compare] changes code behavior on autofix if strictNullCheck is disabled. #2830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why do you have strictNullChecks turned off? This rule (like all rules in the same vein) will not work correctly and will cause issues without it. You should not be using this rule without strictNullChecks. |
I would rather have it on, but our Typescript codebase is 250k lines and it cannot 'just' be activated. That would be a two weeks task. However, this does not matter. Calling In our case the eslint configuration is shared throughout the company for many projects. Our project is a banking application and I just found out about the change because the tests failed after running eslint with an updated configuration. There should at least be a warning or an error message if this rule is active and |
TypeScript just says to the rule that "variable This is why the rule autofixes - the rule is acting based on the information that it is given. I probably should have included this rule when I did #2345, but I didn't think about it at the time. To reiterate: |
Would you mind adding a note to the rule documentation? https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md Other people might run into the same issue. It would be good if TypeScript said to the rule that "variable |
It will - if and only if Which is why it's so very, very dangerous to ever code with
Happy to accept PR. Everything here is open source and community maintained. |
…ning message Added a warning message to the rule readme since this rule can change the behaviour of a program if `strictNullChecks` is disabled. Fixes typescript-eslint#2830
Uh oh!
There was an error while loading. Please reload this page.
This issue is related to #1632.
When
strictNullChecks
is disabled, autofix for this rule changes the actual behaviour of the code, which can cause new bugs.In that case, autofix should be disabled for this rule.
Repro
Expected Result
or
Actual Result
Additional Info
tsconfig:
Versions
@typescript-eslint/eslint-plugin
4.8.2
@typescript-eslint/parser
4.8.2
TypeScript
4.0.5
ESLint
7.9.0
node
12.19.0
The text was updated successfully, but these errors were encountered: