[英]How to use eslint autofix in .vue?
I want to use autofix in .vue
file, but Eslint only show the errors, no autofix.我想在
.vue
文件中使用自动修复,但 Eslint 只显示错误,没有自动修复。
How do I configure the .eslintrc
to make it work?如何配置
.eslintrc
使其工作?
Assuming Vue.js 3, in your root directory, create a file vue.config.js
, if not exists already, and insert:假设 Vue.js 3,在你的根目录下,创建一个文件
vue.config.js
,如果不存在,然后插入:
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
chainWebpack: config => {
config
.plugin('eslint')
.tap(args => {
args[0].fix = true
return args
})
}
})
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).
我也在Github上问过他们,答案是他们还没有找到使用插件修复程序(vue-loader)的解决方案。
Eslint and VueJS files. Eslint和VueJS文件。 Throwing errors but not fixing them
抛出错误但没有修复它们
Here is thread on Github of Eslint: https://github.com/eslint/eslint/issues/7456#issuecomment-256757117 这是Eslint的Github上的帖子: https : //github.com/eslint/eslint/issues/7456#issuecomment-256757117
Hope it helps. 希望能帮助到你。
尝试使用它指定文件扩展名
eslint --fix --ext .js,.vue src
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.