简体   繁体   中英

babel.config.js babel eslint turn off / disable a rule

I would like to deactivate a babel eslint rule no-unused-vars .

if using to eslint (not babel-eslint) I would add the following

.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.

I was able to add a "eslintConfig" section to my package.json and it was respected by my linter running on every build.

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"
        }
    },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM