[英]babel.config.js babel eslint turn off / disable a rule
I would like to deactivate a babel eslint rule no-unused-vars
.我想停用 babel eslint 规则
no-unused-vars
。
if using to eslint (not babel-eslint) I would add the following如果使用 eslint(不是 babel-eslint),我会添加以下内容
.eslintrc.js
rules: {
'no-unused-vars': 'off'
}
So I tried adding the same code to所以我尝试将相同的代码添加到
babel.config.js
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
rules: {
'no-unused-vars': 'off'
}
}
but this generates an error但这会产生错误
ERROR ReferenceError: Unknown option: .rules. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
I can find no mention of rules in the docs.我找不到文档中提到的规则。 I tried
exclude
but that did not work in disabling the rule.我试过
exclude
但在禁用规则时不起作用。
I was able to add a "eslintConfig"
section to my package.json and it was respected by my linter running on every build.我能够向我的 package.json 添加一个
"eslintConfig"
部分,并且我的 linter 在每个构建中运行时都尊重它。
I might suggest adding your rules there.我可能会建议在那里添加您的规则。
You might need to change some plugins or other configs, but I removed those from the snippet to cut down on the size.您可能需要更改一些插件或其他配置,但我从代码片段中删除了它们以减少大小。
"eslintConfig": {
[... removed for brevity]
"parser": "@babel/eslint-parser"
"rules": {
"no-unused-vars": "off"
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.