$("#ID").hide();
ฉันเพิ่ม ESLint ในโครงการของฉัน
$
ทุกอย่างดียกเว้นสัญลักษณ์
ฉันได้รับข้อผิดพลาด: [eslint] '$' is not defined. (no-undef)
ของฉัน.eslintrc.json
(หมายเหตุ: มีกฎเพิ่มเติมที่ตั้งค่าให้ไม่อนุญาตฟังก์ชัน jquery เมื่อมีจาวาสคริปต์ที่เทียบเท่า):
{
"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-signและ eslint-plugin-jquery
ทำไมกฎนี้ไม่ทำงาน
"dollar-sign/dollar-sign": [
2,
"ignoreProperties"
]