[英]Define is not defined (ESLint)
I keep getting an ESLint error 'define' is not defined. (no-undef)
我一直得到一个ESLint错误
'define' is not defined. (no-undef)
'define' is not defined. (no-undef)
. 'define' is not defined. (no-undef)
。 I believe, I could just define define
globally, but shouldn't this be supported natively? 我相信,我可以
define
全局define
,但不应该本地支持吗?
A code example using define: 使用define的代码示例:
define([], function () { // Error here!
'use strict';
....
This is my eslintrc.json: 这是我的eslintrc.json:
{
"env": {
"shared-node-browser": true,
"commonjs": true
},
"plugins": ["requirejs"],
"extends": ["eslint:recommended"],
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"requirejs/no-invalid-define": 2,
"requirejs/no-multiple-define": 2,
"requirejs/no-named-define": 2,
"requirejs/no-commonjs-wrapper": 2,
"requirejs/no-object-define": 1
}
}
In your .eslintrc.json
set: 在你的
.eslintrc.json
集合中:
"env": {
"amd": true
},
When the "amd" environment is turned on, eslint registers globals for define
and require
. 当“amd”环境打开时,eslint会将globals注册为
define
和require
。
I would also turn off the "commonjs"
environment unless you really are mixing both AMD and CommonJS in the same code base. 除非你真的在相同的代码库中混合AMD和CommonJS,否则我也会关闭
"commonjs"
环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.