-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
prefer-optional-chain autofix is not safe #1820
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
Happy to accept a PR to add an option to convert the fixer to a suggestion fixer. My general suggestion is to avoid This is also very easy to enforce with the base
|
I think autofix should be completely logical equality. Shall autofix only open in IfStatement. Or if the optional chains is in 'Assign Expression'(BinarayExpression with EqualsToken), the autofix should be closed. |
Set both the the base eqeqeq rule to |
It's only as dangerous as your types are. The fixer in its current form may or may not cause type errors, depending on your codebase and the checks that are done on your code. A suggestion fixer will let people manually apply the fix in their IDE, and will not let it be fixed automatically via |
The autofix of rule "prefer-optional-chain" in eslint-plugin is not safe in this case:
source code:
autofixed code:
The text was updated successfully, but these errors were encountered: