admin管理员组文章数量:1333211
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?
4 Answers
Reset to default 7The 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,
本文标签: javascriptChange 39shouldFix39 parameter in ESLintStack Overflow
版权声明:本文标题:javascript - Change 'shouldFix' parameter in ESLint - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742246520a2439885.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论