未定义ESLint dollar($). (没有undef) [英] ESLint dollar($) is not defined. (no-undef)
问题描述
$("#ID").hide();
我将ESLint添加到我的项目中.
i add ESLint to my project .
一切正常,除了符号$
.
我收到错误消息:[eslint] '$' is not defined. (no-undef)
我的.eslintrc.json
(注意:它已将其他规则设置为禁止使用jquery函数如果有一个等效的javascript):
my .eslintrc.json
(note: it has additional rules set to disallow jquery functions when there's an equivalent javascript one):
{
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": [
"eslint:recommended"
],
"parserOptions": {
"sourceType": "module"
},
"plugins": [
"dollar-sign",
"jquery"
],
"rules": {
"indent": [
"error" ,
"tab"
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"jquery/no-ajax": 2,
"jquery/no-animate": 2,
"jquery/no-attr": 2,
"jquery/no-bind": 2,
"jquery/no-class": 2,
"jquery/no-clone": 2,
"jquery/no-closest": 2,
"jquery/no-css": 2,
"jquery/no-data": 2,
"jquery/no-deferred": 2,
"jquery/no-delegate": 2,
"jquery/no-each": 2,
"jquery/no-fade": 2,
"jquery/no-filter": 2,
"jquery/no-find": 2,
"jquery/no-global-eval": 2,
"jquery/no-has": 2,
"jquery/no-hide": 2,
"jquery/no-html": 2,
"jquery/no-in-array": 2,
"jquery/no-is": 2,
"jquery/no-map": 2,
"jquery/no-merge": 2,
"jquery/no-param": 2,
"jquery/no-parent": 2,
"jquery/no-parents": 2,
"jquery/no-parse-html": 2,
"jquery/no-prop": 2,
"jquery/no-proxy": 2,
"jquery/no-serialize": 2,
"jquery/no-show": 2,
"jquery/no-sizzle": 2,
"jquery/no-slide": 2,
"jquery/no-text": 2,
"jquery/no-toggle": 2,
"jquery/no-trigger": 2,
"jquery/no-trim": 2,
"jquery/no-val": 2,
"jquery/no-wrap": 2,
"dollar-sign/dollar-sign": [
2,
"ignoreProperties"
]
}
您可以看到我添加了两个插件: eslint-plugin-dollar-签名和eslint-plugin-jquery.
you can see that I have added two plugins: eslint-plugin-dollar-sign and eslint-plugin-jquery.
为什么此规则不起作用?
why does not work this rule ?
"dollar-sign/dollar-sign": [
2,
"ignoreProperties"
]
"dollar-sign/dollar-sign": [
2,
"ignoreProperties"
]
推荐答案
您丢失了
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jquery": true
},
如果未启用jquery
环境,则不会将
$
声明为全局变量.因此,您将得到一个no-undef
错误,表示您正在使用尚未声明的变量.
$
is not declared as a global without jquery
environment enabled. Because of that, you are getting a no-undef
error, saying that you are using variable that haven't been declared.
这篇关于未定义ESLint dollar($). (没有undef)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!