【发布时间】:2017-04-29 03:24:32
【问题描述】:
我正在尝试在我的根目录上将 ESLINT 与 eslint . 一起使用并遇到此错误:
YAMLException: Cannot read config file:
/mypath/node_modules/extend/.eslintrc Error:
duplicated mapping key at line 45, column 30: "beforeLineComment": false,
我有节点 v6.9.1 eslint 是 v3.12.1
这是我的 .eslintrc.json 配置文件:
{
"rules": {
"indent": [2, 2],
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"no-underscore-dangle": 0,
"curly": 0,
"no-use-before-define": [2, "nofunc"],
"spaced-comment": [2, "always"],
"space-before-function-paren": [2, { "anonymous": "always", "named": "never" }],
"space-after-keywords": [2, "always"],
"space-before-blocks": [2, "always"],
"semi-spacing": [2, {"before": false, "after": true}],
"no-var": 2,
"object-shorthand": [2, "always"],
"prefer-const": 2
},
"env": {
"es6": true,
"node": true,
"mocha": true
}
}
如您所见,我使用的是 json 而非 YAML,我不知道为什么会出现该错误。
【问题讨论】:
-
该文件甚至没有 45 行。您确定就是它抱怨的文件吗?
-
除非指定
"root": true,否则eslint会合并.eslintrc文件with files found in parent directories。也许这种合并涉及一些 YAML 转换,并且父目录中的.eslintrc文件中可能有一些奇怪的东西?
标签: javascript json ecmascript-6 eslint