If you want esLint to run across your code in one commit, call npx eslint . --fix.
This will run eslint and attempt to fix all possible issues (such as import sorting) that it can.
In my vsCode settings.json I have the following:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.ignoreUntitled": true,
"eslint.validate": ["javascript", "typescript"],
"eslint.format.enable": true,
"eslint.run": "onSave",
This will then run eslint on save to correct issues like imports or let => const
Also, make sure VScode is updated; on ubuntu, it took updating the app to get this working.
Answer from Shadoath on Stack OverflowIf you want esLint to run across your code in one commit, call npx eslint . --fix.
This will run eslint and attempt to fix all possible issues (such as import sorting) that it can.
In my vsCode settings.json I have the following:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.ignoreUntitled": true,
"eslint.validate": ["javascript", "typescript"],
"eslint.format.enable": true,
"eslint.run": "onSave",
This will then run eslint on save to correct issues like imports or let => const
Also, make sure VScode is updated; on ubuntu, it took updating the app to get this working.
If you are using yarn you can use
yarn eslint . --fix.
It will run autofixes across all files and show you all errors and warnings too.
» npm install eslint-plugin-sort-imports-es6-autofix
» npm install eslint-plugin-simple-import-sort
» npm install @youre/eslint-plugin-sort-imports-es6-autofix