I am experiencing an intermittent problem with ESLint in VS Code. When saving a file, instead of formatting it, this message shows in the status bar:
Apparently no one has ever reported this message on Google.
When I say it is intermittent, it was working fine, then the computer (MBP) crashed, and on restarting this is the situation. It has happened previously, but I don't recall what I did to fix it.
The app is a fairly complex Vue-based app based on a pre-configured template. In package.json:
"@vue/cli-plugin-eslint": "^4.5.13",
"babel-eslint": "^10.1.0",
"eslint": "^7.31.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-vue": "^7.14.0",
In the VS Code workspace file:
"editor.codeLens": true,
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[vue]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"eslint.validate": [
"javascript"
],
"debug.javascript.usePreview": true,
"debug.javascript.usePreviewAutoAttach": true,
"[jsonc]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
I'm really not sure how to proceed to understand why vscode-eslint is reporting that it can't format JavaScript files.
EDIT
This issue regarding TypeScript gives some hints. It seems this error can result when the ESLint server is restarting or the extension host is under a lot of stress.
In my project now, most files are formatting fine, although one consistently fails. That file is called eslint.js
and is part of a build process, running eslint - I don't totally understand the configuration. I suspect that saving this file somehow causes eslint to be run/reloaded, and while that is happening, eslint-vscode tries to also run it and fails.
ESLint comes with several built-in formatters to control the appearance of the linting results, and supports third-party formatters as well. You can specify a formatter using the --format or -f flag on the command line. For example, --format json uses the json formatter.
In your code editor, open the JavaScript file you created earlier. All the broken rules will be indicated. If you have the ESLint extension installed you can use CTRL+SHIFT+P to open the Command Palette. Then search for ESLint: Fix all auto-fixable Problems and press ENTER (or RETURN ).
ESLint supports you and teams to follow a common code style in your project. It can be used in VS Code by installing it from the VS Code Marketplace. Once you have integrated it in VS Code, you can configure ESLint to enforce a code style in your files.
This issue regarding TypeScript gives some hints. It seems this error can result when the ESLint server is restarting or the extension host is under a lot of stress. In my project now, most files are formatting fine, although one consistently fails.
How To Lint and Format Code with ESLint in Visual Studio Code Step 1 — Creating JavaScript Starter Code. You need to start with a demo project. ... Open app.js in Visual Studio Code. Step 2 — Setting Up ESLint. It’s important to include the --save-dev flag because this saves the package as a ...
The ESLint extension has no support for formatting selections since ESLint itself (the npm module) has not API for it. This is the reason why you can't do it.
JavaScript (ESM) - use .eslintrc.cjs when running ESLint in JavaScript packages that specify "type":"module" in their package.json. Note that ESLint does not support ESM configuration at this time. YAML - use .eslintrc.yaml or .eslintrc.yml to define the configuration structure. JSON - use .eslintrc.json to define the configuration structure.
I was actually experiencing the same problem and I only needed to remove the .eslintignore
file, which only contained this line:
.eslintrc.js
You could simply comment that line too.
Hope that helps :)
I was fighting with this for a while, turns out you need to head to Settings
, under User
go to Extensions > ESLint
, scroll down to Format:Enable
and enable ESLint
as a formatter.
Settings:
This can happen for a variety of reasons. The eslint output logs will tell you the issue.
In my case the settings field configFile
was changed to overrideConfigFile
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