我在GitLab
. 我更改了.eslint.json
使用来自 StackOverflow 的信息的设置。但我仍然有问题。
我的.eslint.json
样子:
{
"extends": "eslint:recommended",
"rules": {
"semi": ["warn", "never"],
"quotes": ["warn", "single"],
"no-console": ["off"]
},
"parserOptions": {
"ecmaVersion": 9
},
"env": {
"es6": true,
"node": true,
"browser": true,
"amd": true
},
"globals": {
"$": true,
"require": true
"process": true
},
"root": true
}
Run Code Online (Sandbox Code Playgroud)
在env
我添加"adm": true
和在globals
我添加"process": true
和"require": true
。
错误是:
错误 'require' 未定义 no-undef
错误“进程”未定义 no-undef
错误所在的文件如下所示:
{
"extends": "eslint:recommended",
"rules": {
"semi": ["warn", "never"],
"quotes": ["warn", "single"],
"no-console": ["off"]
},
"parserOptions": {
"ecmaVersion": 9
},
"env": {
"es6": true,
"node": true,
"browser": true,
"amd": true
},
"globals": {
"$": true,
"require": true
"process": true
},
"root": true
}
Run Code Online (Sandbox Code Playgroud)
那么问题出在哪里呢?这是 env 节点的问题吗?我该如何解决这个问题?
Raj*_*jan 75
要在配置文件中指定环境,请使用 env 键并通过将 each 设置为 true 来指定要启用的环境。例如,以下启用浏览器、es6 和 Node.js 环境:
在您的.eslintrc.js
文件中;
...
env: {
browser: true,
node: true, <<<<--- Add this
es6: true
},
...
Run Code Online (Sandbox Code Playgroud)
重命名.eslint.json
为.eslintrc.json
或确保eslintConfig
在 package.json 中指定
https://eslint.org/docs/user-guide/configuring
还要确保它eslint
在 .eslintrc.json 所在的目录中启动,并且不使用--no-eslintrc
选项启动。
归档时间: |
|
查看次数: |
12274 次 |
最近记录: |