I want to use autofix in .vue
file, but Eslint only show the errors, no autofix.
How do I configure the .eslintrc
to make it work?
Set up ESLint to autofix files To enable running eslint --fix on save for the current project, go to Preferences / Settings | Languages and Frameworks | JavaScript | Code Quality Tools | ESLint and tick the Run eslint --fix on save checkbox. By default, WebStorm will run ESLint to autofix . js, .
Running ESLint from the command line If you want to run eslint from the command line, make sure you include the . vue extension using the --ext option or a glob pattern, because ESLint targets only . js files by default. If you installed @vue/cli-plugin-eslint , you should have the lint script added to your package.
If you're using a project created with @vue/cli , you'll find the ESLint config inside package. json under the eslintConfig property.
ESLint editor integrations are useful to check your code in real-time. Status of Vue.js 3.x supports. This plugin supports the basic syntax of Vue. js 3.2, <script setup> , and CSS variable injection, but the ref sugar, an experimental feature of Vue. js 3.2, is not yet supported.
Try to use it with specifying files extensions
eslint --fix --ext .js,.vue src
vue 3 -> vue.config.js
module.exports = defineConfig({
chainWebpack: config => {
config
.plugin('eslint')
.tap(args => {
args[0].fix = true
return args
})
}
})
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