-
Notifications
You must be signed in to change notification settings - Fork 470
/
eslint.config.js
201 lines (186 loc) · 3.71 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import jqueryConfig from "eslint-config-jquery";
import importPlugin from "eslint-plugin-import";
import globals from "globals";
export default [
{
// Only global ignores will bypass the parser
// and avoid JS parsing errors
// See https://github.com/eslint/eslint/discussions/17412
ignores: [ "external", "null.json", "simple.json" ]
},
{
files: [ "eslint.config.js", "build/**" ],
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.node
}
},
rules: jqueryConfig.rules
},
{
files: [ "src/**" ],
plugins: {
import: importPlugin
},
languageOptions: {
ecmaVersion: 2015,
// The browser env is not enabled on purpose so that code takes
// all browser-only globals from window instead of assuming
// they're available as globals. This makes it possible to use
// jQuery with tools like jsdom which provide a custom window
// implementation.
globals: {
jQuery: false,
window: false
}
},
rules: {
...jqueryConfig.rules,
"import/extensions": [ "error", "always" ],
"import/no-cycle": "error",
indent: [
"error",
"tab",
{
outerIIFEBody: 0,
// This makes it so code within if statements checking
// for jQuery features is not indented.
ignoredNodes: [ "Program > IfStatement > *" ]
}
],
"one-var": [ "error", { var: "always" } ],
strict: [ "error", "function" ]
}
},
{
files: [ "src/wrapper.js" ],
languageOptions: {
sourceType: "script",
globals: {
jQuery: false,
define: false,
module: false
}
},
rules: {
"no-unused-vars": "off",
indent: [
"error",
"tab",
{
// This makes it so code within the wrapper is not indented.
ignoredNodes: [
"Program > ExpressionStatement > CallExpression > :last-child > *"
]
}
]
}
},
{
files: [ "test/unit/**" ],
languageOptions: {
ecmaVersion: 2015,
sourceType: "script",
globals: {
...globals.browser,
jQuery: false,
QUnit: false,
url: false,
expectWarning: false,
expectNoWarning: false,
compareVersions: false,
jQueryVersionSince: false,
startIframeTest: false,
TestManager: false
}
},
rules: {
...jqueryConfig.rules,
"no-unused-vars": [
"error",
{ args: "after-used", argsIgnorePattern: "^_" }
]
}
},
{
files: [ "test/data/**" ],
ignores: [ "test/data/jquery-*.js", "test/data/qunit-start.js" ],
languageOptions: {
ecmaVersion: 2015,
sourceType: "script",
globals: {
...globals.browser,
global: false,
jQuery: false,
QUnit: false,
url: true,
compareVersions: true,
expectWarning: true,
expectNoWarning: true,
startIframeTest: true,
TestManager: true
}
},
rules: {
...jqueryConfig.rules,
strict: [ "error", "global" ]
}
},
{
files: [ "test/runner/**" ],
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.node
},
sourceType: "module"
},
rules: {
...jqueryConfig.rules
}
},
{
files: [ "test/runner/listeners.js" ],
languageOptions: {
ecmaVersion: 5,
globals: {
...globals.browser,
QUnit: false,
Symbol: false
},
sourceType: "script"
},
rules: {
...jqueryConfig.rules,
strict: [ "error", "function" ]
}
},
{
files: [ "dist/jquery-migrate.js" ],
languageOptions: {
globals: {
define: false,
jQuery: false,
module: false,
Proxy: false,
Reflect: false,
window: false
}
},
rules: {
...jqueryConfig.rules,
strict: [ "error", "function" ],
// These are fine for the built version
"no-multiple-empty-lines": "off",
"one-var": "off"
}
},
{
files: [ "dist/**" ],
languageOptions: {
ecmaVersion: 5,
sourceType: "script"
}
}
];