[英]How to configure eslint in Vue?
I have started a new Vue project, but all the configuration files (webpack, ...) are not there anymore.我已经开始了一个新的 Vue 项目,但是所有的配置文件(webpack,...)都不在了。 Now everything is hidden within Vue and I don't know how to configure it.
现在一切都隐藏在 Vue 中,我不知道如何配置它。
My issue is that all notices and warnings are treated as errors by eslint:我的问题是所有通知和警告都被 eslint 视为错误:
error: 'Segment' is defined but never used (no-unused-vars) at src/App.vue:10:8:
8 | <script>
9 | import HelloWorld from './components/HelloWorld.vue'
> 10 | import Segment
This should be a notice not a critical error.这应该是通知而不是严重错误。
I would like to change that, but the default configuation in my package.json
is:我想改变它,但我的
package.json
的默认配置是:
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
Is there and development
mode or something similar?有没有和
development
模式或类似的东西?
For example you can disable not defined
and not used
warning:例如,您可以禁用
not defined
和not used
警告:
in package.json:在 package.json 中:
"eslintConfig": {
"rules": {
"no-unused-vars": "off",
"no-undef": "off"
},
},
There's currently no configuration out of the box that configures all rules to be warnings, but you could accomplish that with an ESLint plugin: eslint-plugin-only-warn
.目前没有开箱即用的配置将所有规则配置为警告,但您可以使用 ESLint 插件来实现:
eslint-plugin-only-warn
。 After installing that module, edit your package.json
's eslintConfig
to contain:安装该模块后,编辑
package.json
的eslintConfig
以包含:
{
"eslintConfig": {
"plugins": [
"only-warn"
]
}
}
Or you could configure those rules individually to be warnings instead of errors:或者您可以将这些规则单独配置为警告而不是错误:
{
"eslintConfig": {
"rules": {
"no-unused-vars": "warn",
"no-undef": "warn"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.