I am trying to lint and fix my code using ESLint. When I run ESLint with my config file and without the fix flag, it runs fine, and this is what it outputs.
eslint-c .eslintrc.json ./src/aura/SearchAvailableNumbers
/home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js
8:9 error Unexpected blank line after variable declarations newline-after-var
15:13 error 'hlp' is defined but never used no-unused-vars
50:30 error 'helper' is defined but never used no-unused-vars
55:32 error 'helper' is defined but never used no-unused-vars
59:42 error 'helper' is defined but never used no-unused-vars
69:7 error Expected { after 'if' condition curly
69:22 error Expected '===' and instead saw '==' eqeqeq
71:22 error Expected '===' and instead saw '==' eqeqeq
76:22 error Expected '===' and instead saw '==' eqeqeq
84:50 error Object properties must go on a new line object-property-newline
89:21 error Expected '===' and instead saw '==' eqeqeq
113:27 error 'appEvent' is already defined no-redeclare
/home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js
14:17 error Gratuitous parentheses around expression no-extra-parens
23:17 error 'appEvent' is defined but never used no-unused-vars
24:28 error Expected '===' and instead saw '==' eqeqeq
28:28 error Expected '===' and instead saw '==' eqeqeq
32:28 error Expected '===' and instead saw '==' eqeqeq
All of that information is correct, and are issues that must be fixed in the code. So I run it again, this time with
eslint --fix --debug -c .eslintrc.json ./src/aura/SearchAvailableNumbers
Now the output is
eslint:cli Running on files +0ms
eslint:config Using command line config .eslintrc.json +70ms
eslint:config-file Loading JSON config file: /home/jason/sfa/testproj/.eslintrc.json +5ms
eslint:config-file Loading /usr/local/lib/node_modules/eslint/conf/eslint.json +292ms
eslint:config-file Loading JSON config file: /usr/local/lib/node_modules/eslint/conf/eslint.json +0ms
eslint:ignored-paths Looking for ignore file in /home/jason/sfa/testproj +40ms
eslint:ignored-paths Could not find ignore file in cwd +0ms
eslint:glob-util Creating list of files to process. +1ms
eslint:cli-engine Processing /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js +6ms
eslint:cli-engine Linting /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js +1ms
eslint:config Constructing config for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js +0ms
eslint:config Using .eslintrc and package.json files +0ms
eslint:config Loading /home/jason/sfa/testproj/.eslintrc.yml +2ms
eslint:config-file Loading YAML config file: /home/jason/sfa/testproj/.eslintrc.yml +1ms
eslint:config-file Loading /usr/local/lib/node_modules/eslint/conf/eslint.json +63ms
eslint:config-file Loading JSON config file: /usr/local/lib/node_modules/eslint/conf/eslint.json +0ms
eslint:config Using /home/jason/sfa/testproj/.eslintrc.yml +5ms
eslint:config Merging command line config file +0ms
eslint:config Merging command line environment settings +0ms
eslint:config-ops Apply environment settings to config +1ms
eslint:config-ops Creating config for environment browser +0ms
eslint:cli-engine Linting code for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js (pass 1) +3ms
eslint:cli-engine Generating fixed text for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js (pass 1) +147ms
eslint:text-fixer Applying fixes +0ms
eslint:text-fixer No fixes to apply +0ms
eslint:cli-engine Processing /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js +0ms
eslint:cli-engine Linting /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js +1ms
eslint:config Constructing config for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js +0ms
eslint:config Using config from cache +0ms
eslint:cli-engine Linting code for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js (pass 1) +0ms
eslint:cli-engine Generating fixed text for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js (pass 1) +56ms
eslint:text-fixer Applying fixes +0ms
eslint:text-fixer No fixes to apply +0ms
eslint:cli-engine Linting complete in: 291ms +1ms
eslint:cli Fix mode enabled - applying fixes +0ms
/home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js
8:9 error Unexpected blank line after variable declarations newline-after-var
15:13 error 'hlp' is defined but never used no-unused-vars
50:30 error 'helper' is defined but never used no-unused-vars
55:32 error 'helper' is defined but never used no-unused-vars
59:42 error 'helper' is defined but never used no-unused-vars
69:7 error Expected { after 'if' condition curly
69:22 error Expected '===' and instead saw '==' eqeqeq
71:22 error Expected '===' and instead saw '==' eqeqeq
76:22 error Expected '===' and instead saw '==' eqeqeq
84:50 error Object properties must go on a new line object-property-newline
89:21 error Expected '===' and instead saw '==' eqeqeq
113:27 error 'appEvent' is already defined no-redeclare
/home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js
14:17 error Gratuitous parentheses around expression no-extra-parens
23:17 error 'appEvent' is defined but never used no-unused-vars
24:28 error Expected '===' and instead saw '==' eqeqeq
28:28 error Expected '===' and instead saw '==' eqeqeq
32:28 error Expected '===' and instead saw '==' eqeqeq
✖ 17 problems (17 errors, 0 warnings)
When I open the actual code, nothing has been changed. When I run the linter again, it outputs the same thing.
It clearly says "generating fixed text" but then it outputs "no fixes to apply". I can't find anything regarding how the fix flag functions online, so I turn to stackoverflow for help.. Thanks in advance.
Not all of the ESLint rules are fixable (actually most of the rules are not fixable as of yet). You can find out which rules can be autofixed by looking for wrench glyph on this page: http://eslint.org/docs/rules/
None of the rules that you have errors for are currently autofixable. Some because the ESLint team hasn't gotten to them yet (like newline-after-var
), some, because it's very likely to create a different logic then was intended in the original code (like eqeqeq
) and some, because it's impossible to figure out the right way to autofix it (like no-unused-vars
and no-redeclare
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With