最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Change 'shouldFix' parameter in ESLint - Stack Overflow

programmeradmin6浏览0评论

I'm using ESLint with its VS Code extension to format my code.

At some point it stopped auto-formatting the code on save. I uninstalled everything and reinstalled anew: VS Code, ESLint and ESLint extension for VS Code.

I think I'm close to making the formatter work, but ESLint logs this in VS Code when I try and save a file with a linting error:

2020-10-10T10:41:45.345Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes

I guess if I find that shouldFix parameter and set it to true it'll work, but where is it?

I'm using ESLint with its VS Code extension to format my code.

At some point it stopped auto-formatting the code on save. I uninstalled everything and reinstalled anew: VS Code, ESLint and ESLint extension for VS Code.

I think I'm close to making the formatter work, but ESLint logs this in VS Code when I try and save a file with a linting error:

2020-10-10T10:41:45.345Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes

I guess if I find that shouldFix parameter and set it to true it'll work, but where is it?

Share Improve this question edited Oct 10, 2020 at 10:45 jonrsharpe 122k30 gold badges267 silver badges474 bronze badges asked Oct 10, 2020 at 10:43 Matteo CarpiMatteo Carpi 5928 silver badges25 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 7

The above solution didn't work for me. I had to explicity add the following to my VSCode settings.

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

I think maybe something in the newest VSCode update municating this with the plugin went wrong.

I managed to fix it changing the .eslintrc.js at the root of the project.

'parserOptions': {
    'ecmaVersion': 12,
}

instead of

'parserOptions': {
    'ecmaVersion': 2018,
}

I don't know why it worked till yesterday and then stopped.... but well that solved it for me.

Configuring a default formatter resolved this for me. From the extension's page:

eslint.format.enable (@since 2.0.0): uses ESlint as a formatter for files that are validated by ESLint. If enabled please ensure to disable other formatters if you want to make this the default. A good way to do so is to add the following setting "[javascript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" } for JavaScript. For TypeScript you need to add "[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" }.

run npm run lint this will start debugging your code with eslint and your error should be solve then,

发布评论

评论列表(0)

  1. 暂无评论