12

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?

3 Answers 3

11

Try to use it with specifying files extensions

eslint --fix --ext .js,.vue src
5

It will not work. I had exactly the same issue and asked this question here (surprised you haven't found it). I also asked them on Github and the answer is that they still not came with solution to use fix with plugins (vue-loader).

Eslint and VueJS files. Throwing errors but not fixing them

Here is thread on Github of Eslint: https://github.com/eslint/eslint/issues/7456#issuecomment-256757117

Hope it helps.

4

Assuming Vue.js 3, in your root directory, create a file vue.config.js, if not exists already, and insert:

const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  chainWebpack: config => {
    config
      .plugin('eslint')
      .tap(args => {
        args[0].fix = true
        return args
      })
  }
})
1
  • that setting creates an endless compiling loop when i execute "npm run serve". I guess its because of some issues that ESLint cannot fix and then it retries it again and again. Any setting to prevent that? Apr 5 at 8:29

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.