Cannot read config file .eslintrc.json Error: Unexpected token }
Cannot read config file .eslintrc.json Error: Unexpected token }
我正在为我的 React JS ES6 项目探索 EsLint,但我立即陷入困境。
我创建了一个 .eslintrc.json 与 here:
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
},
"rules": {
"semi": 2
}
}
我现在该怎么办?
Cannot read config file: /Users/eric/af/frontend_app/.eslintrc.json
Error: Unexpected token }
SyntaxError: Cannot read config file: /Users/eric/af/frontend_app/.eslintrc.json
Error: Unexpected token }
at Object.parse (native)
at loadJSONConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:117:21)
at loadConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:210:26)
at Object.load (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:437:18)
at loadConfig (/usr/local/lib/node_modules/eslint/lib/config.js:67:33)
at getLocalConfig (/usr/local/lib/node_modules/eslint/lib/config.js:129:23)
at Config.getConfig (/usr/local/lib/node_modules/eslint/lib/config.js:223:22)
at processText (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:155:27)
at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:227:18)
at executeOnFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:603:23)
我的 EsLint 版本:
$ eslint -v
v2.4.0
我已经尝试将同一个配置文件的名称更改为 。eslintrc.js 我得到了这个:
Cannot read config file: /Users/eric/af/frontend_app/.eslintrc.js
Error: /Users/eric/af/frontend_app/.eslintrc.js:2
"parserOptions": {
^
Unexpected token :
/Users/eric/af/frontend_app/.eslintrc.js:2
"parserOptions": {
^
SyntaxError: Unexpected token :
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at module.exports (/usr/local/lib/node_modules/eslint/node_modules/require-uncached/index.js:14:12)
at loadJSConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:157:16)
at loadConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:197:22)
像这样(我去掉了"ecmaFeatures": {"jsx": true},
后面的逗号):
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": 2
}
}
使用此工具验证您的 json : http://jsonlint.com/
我正在为我的 React JS ES6 项目探索 EsLint,但我立即陷入困境。 我创建了一个 .eslintrc.json 与 here:
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
},
"rules": {
"semi": 2
}
}
我现在该怎么办?
Cannot read config file: /Users/eric/af/frontend_app/.eslintrc.json
Error: Unexpected token }
SyntaxError: Cannot read config file: /Users/eric/af/frontend_app/.eslintrc.json
Error: Unexpected token }
at Object.parse (native)
at loadJSONConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:117:21)
at loadConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:210:26)
at Object.load (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:437:18)
at loadConfig (/usr/local/lib/node_modules/eslint/lib/config.js:67:33)
at getLocalConfig (/usr/local/lib/node_modules/eslint/lib/config.js:129:23)
at Config.getConfig (/usr/local/lib/node_modules/eslint/lib/config.js:223:22)
at processText (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:155:27)
at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:227:18)
at executeOnFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:603:23)
我的 EsLint 版本:
$ eslint -v
v2.4.0
我已经尝试将同一个配置文件的名称更改为 。eslintrc.js 我得到了这个:
Cannot read config file: /Users/eric/af/frontend_app/.eslintrc.js
Error: /Users/eric/af/frontend_app/.eslintrc.js:2
"parserOptions": {
^
Unexpected token :
/Users/eric/af/frontend_app/.eslintrc.js:2
"parserOptions": {
^
SyntaxError: Unexpected token :
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at module.exports (/usr/local/lib/node_modules/eslint/node_modules/require-uncached/index.js:14:12)
at loadJSConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:157:16)
at loadConfigFile (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:197:22)
像这样(我去掉了"ecmaFeatures": {"jsx": true},
后面的逗号):
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": 2
}
}
使用此工具验证您的 json : http://jsonlint.com/