question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ESLint@^8 cannot format the code when saving

See original GitHub issue

Hi, After my test, ESLint@^8 cannot format the code when saving with the following configuration, and versions ^5 to ^7 do fine.

"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
}

I don’t know if this issue is reported to eslint or vscode-eslint.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
MariaSolOscommented, Nov 8, 2022

@vvizden I just cloned your repo and everything worked for me.

Seems because of this config: "eslint.codeActionsOnSave.rules": [],

That makes sense. That setting lists the rules that should be auto-fixed when saving/formatting a file. If it’s empty, the extension will not make any changes. If not defined, then the default is to use the rules in the .eslintrc file.

But why is versions ^5 to ^7 not affected by it.

Good question. The README says: image

So what I think was happening is that with earlier versions of ESLint this extension would just ignore your "eslint.codeActionsOnSave.rules": [] setting, but now that you’ve upgraded to v8 it results in the behavior explained above.

1reaction
vvizdencommented, Nov 8, 2022

Thank you very much for the careful answer, and here is a summary to help friends who encounter the same problem.

Solve this problem quickly:

It doesn’t matter which version of eslint ( now the latest version is 8.27.0 ) in package.json, just remove the "eslint.codeActionsOnSave.rules": [] in your VSCode settings.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extension 'eslint' is configured as formatter but it cannot format ...
I am experiencing an intermittent problem with ESLint in VS Code. When saving a file, instead of formatting it, this message shows in...
Read more >
v2.1.10 - Extension 'ESlint' cannot format file · Issue #1086
Same issue for me while using insiders build of vs code. I have the default formatter set to "dbaeumer.vscode-eslint" and it no longer...
Read more >
How to Format Code on Save in VS Code with ESlint
Finally, it's time to configure VS Code to auto-format code with ESLint whenever you save a file. You can do this in one...
Read more >
How To Enable Linting on Save with Visual Studio Code and ...
Learn how to lint your code on every file save using ESLint rules and VS Code settings.
Read more >
VS Code - You don't need a formatting extension (Prettier and ...
I don't use React, so I can't comment how well React code is formatted. Settings added to control the formatting of CSS, LESS,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found