简体   繁体   中英

Eslint gives error: Configuration for rule "strict" is invalid: Value "error" is the wrong type

I tried to use Eslint with the following option:

 { "rules": { "indent": [ 2, 2, { "SwitchCase": 1 } ], "space-before-function-paren": [ 2, { "anonymous": "always", "named": "never" } ], "no-use-before-define": [ 2, "nofunc" ], // TODO: turn on later "comma-dangle": [ 0 ], "prefer-template": 0 }, "env": { "node": true, "mocha": true }, "extends": [ "eslint:recommended", "airbnb/base" ] }

And I am getting the error:

Error: ... ... /node_modules/eslint-config-airbnb-base/index.js: Configuration for rule "strict" is invalid: Value "error" is the wrong type.

Referenced from: airbnb/base

I think that this value: 'error' is causing the error.

eslint-config-airbnb-base/rules/strict.js

 module.exports = { rules: { // babel inserts `'use strict';` for us strict: ['error', 'never'] } };

How can I resolve this error?

Severity configuration strings ( "off" , "warn" and "error" ) were introduced in version 2.3.0 of ESLint. Upgrading to that - or a later - version should fix your problem.

If you don't have the eslint resource file .eslintrc.json in your project root with the "rules.semi" set, you can also have this problem.

This sample resource file can fix the error

$ cat .eslintrc.json 
{
    "parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module",
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "rules": {
        "semi": "error"
    }
}

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