Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

--fix doesn't fix the errors using eslint

I'm using eslint in visual code to format the js files but it gives me errors everytime i run it, here's my command line to run it node ./node_modules/eslint/bin/eslint -- src --fix the error message

E:\PATH\src\reducers\roote-reducer.js   1:8   error  There should be no space after '{'                object-curly-spacing   1:26  error  There should be no space before '}'               object-curly-spacing   6:1   error  Expected indentation of 1 tab but found 2 spaces  indent   7:1   error  Expected indentation of 1 tab but found 2 spaces  indent   8:4   error  Newline required at end of file but not found     eol-last  E:\PATH\src\reducers\schedule-reducer.js    1:8   error  There should be no space after '{'                  object-curly-spacing    1:22  error  There should be no space before '}'                 object-curly-spacing    4:1   error  Expected indentation of 1 tab but found 4 spaces    indent    7:24  error  Missing space before function parentheses           space-before-function-paren    7:54  error  Missing space before opening brace                  space-before-blocks    8:1   error  Expected indentation of 1 tab but found 4 spaces    indent    9:1   error  Expected indentation of 1 tab but found 4 spaces    indent  E:\PATH\src\register-service-worker.js    12:1  error  Expected indentation of 1 tab but found 2 spaces    indent    17:1  error  Expected indentation of 5 tabs but found 6 spaces   indent    17:7  error  Use regex shorthands to improve readability         unicorn/regex-shorthand    22:1  error  Expected indentation of 1 tab but found 2 spaces    indent  ✖ 309 problems (309 errors, 0 warnings)   309 errors, 0 warnings potentially fixable with the `--fix` option. 

How can i fix them automatically?

like image 915
gretty volk Avatar asked Jul 10 '18 12:07

gretty volk


People also ask

Can ESLint fix break code?

While ESLint (when running with --fix ) tries hard not to break your code functionally, any time you're manipulating your code in the time between writing it and running it you are putting yourself at risk of changing the behavior of your codebase.


1 Answers

To use --fix option, you need to run eslint directly.

Try this

./node_modules/.bin/eslint src --fix 

On Windows:

.\node_modules\.bin\eslint src\** --fix 
like image 178
piuspbd Avatar answered Sep 22 '22 13:09

piuspbd