1

I'm running eslint v1.8.0 against this test.js file:

require('fs');
var a = 1;

At first, my .eslintrc file is blank:

{
}

Running eslint test.js returns:

1:1  error  "require" is not defined       no-undef
1:9  error  Strings must use doublequote   quotes
2:5  error  "a" is defined but never used  no-unused-vars

This is a node app, though, so I need to tweak it a bit. Running eslint --env node test.js returns:

1:9  error  Strings must use doublequote   quotes
2:5  error  "a" is defined but never used  no-unused-vars

Perfect, that's exactly what I want. So I modify my .eslintrc file to be:

{
    "env": {
        "node": true
    }
}

When I run estlint test.js file now, it returns nothing at all. Why does adding this to my .eslintrc remove the quotes and no-unused-vars warnings?

4

1 回答 1

2

eslint 1.0.0 之后,所有规则默认关闭。所以如果你在没有规则的情况下运行 eslint,你应该得到 0 个结果。这告诉我,您可能在文件夹链向上或向下的某个位置有 .eslintrc 文件,该文件正在被拾取。使用 --debug 标志运行 eslint 以了解从哪里选择设置。

于 2015-11-04T16:45:00.687 回答