-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Bug: --fix ignores defined order and creates a JS error #13899
Copy link
Copy link
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionautofixThis change is related to ESLint's autofixing capabilitiesThis change is related to ESLint's autofixing capabilitiesbugESLint is working incorrectlyESLint is working incorrectlyruleRelates to ESLint's core rulesRelates to ESLint's core rules
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionautofixThis change is related to ESLint's autofixing capabilitiesThis change is related to ESLint's autofixing capabilitiesbugESLint is working incorrectlyESLint is working incorrectlyruleRelates to ESLint's core rulesRelates to ESLint's core rules
Tell us about your environment
What parser (default,
@babel/eslint-parser,@typescript-eslint/parser, etc.) are you using?default
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Eslint command:
What did you expect to happen?
transform variable to constant but not remove the undefined init as it will become a constant.
What actually happened? Please include the actual, raw output from ESLint.
I have runned an autofix in a legacy code with more than 10k files. When it finds a variable that should be a constant (because it is not reasigned) and is initialized as
undefinedit fix the code transforming it toconst foo;causing errors over the code. I tried to change the rules order to first turns it to a constant and them check the undefined init so it should be fixed (as per: https://eslint.org/docs/rules/no-undef-init). But is still happening.Are you willing to submit a pull request to fix this bug?
Yes, need some guidance but I can do this :)