简体   繁体   中英

disabling dot-notation in eslint

I'm having trouble disabling dot-notation in eslint. Below is my eslint config (for the toy example):

module.exports = {
    "env": {
        "browser": true
    },
    "extends": "eslint:recommended",
    "rules": {
        "indent": [
            "error",
            4
        ],
        "dot-notation": 0,
        "no-console": 0,
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "double"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
};

And here is my javascript:

var x = { a: 3 };
console.log("x[a] = " + x["a"]);

According to this , 0 is the way to turn off this eslint option. What am I doing wrong?

Setting a rule value to 0 turns the rule off completely. This means that ESLint will not complain if you try to use an indexer rather than dot notation. It sounds like you're expecting the rule to either throw a warning or error which means that you need either a value of 1 (or warn ) or 2 (or error ) depending on how you want ESLint to behave.

The "Configuring Rules" section of "Configuring ESLint" should make it a little more clear:

https://eslint.org/docs/user-guide/configuring#configuring-rules

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