Tests: include github ref in concurrency group
[jquery.git] / eslint.config.js
blobfb70e1a885ded66d465ecad942b4887136d2b04c
1 import jqueryConfig from "eslint-config-jquery";
2 import importPlugin from "eslint-plugin-import";
3 import globals from "globals";
5 export default [
6         {
8                 // Only global ignores will bypass the parser
9                 // and avoid JS parsing errors
10                 // See https://github.com/eslint/eslint/discussions/17412
11                 ignores: [
12                         "external",
13                         "**/tmp",
14                         "test/data/json_obj.js"
15                 ]
16         },
18         {
19                 files: [
20                         "eslint.config.js",
21                         "Gruntfile.cjs",
22                         "test/bundler_smoke_tests/**/*",
23                         "test/node_smoke_tests/**",
24                         "test/promises_aplus_adapters/**",
25                         "test/middleware-mockserver.cjs"
26                 ],
27                 languageOptions: {
28                         globals: {
29                                 ...globals.node
30                         }
31                 },
32                 rules: {
33                         ...jqueryConfig.rules,
34                         strict: [ "error", "global" ]
35                 }
36         },
38         // Source
39         {
40                 files: [ "src/**" ],
41                 plugins: {
42                         import: importPlugin
43                 },
44                 languageOptions: {
46                         // The browser env is not enabled on purpose so that code takes
47                         // all browser-only globals from window instead of assuming
48                         // they're available as globals. This makes it possible to use
49                         // jQuery with tools like jsdom which provide a custom window
50                         // implementation.
51                         globals: {
52                                 window: false
53                         }
54                 },
55                 rules: {
56                         ...jqueryConfig.rules,
57                         "import/extensions": [ "error", "always" ],
58                         "import/no-cycle": "error",
60                         // TODO: Enable this rule when eslint-plugin-import supports
61                         // it when using flat config.
62                         // See https://github.com/import-js/eslint-plugin-import/issues/2556
64                         // "import/no-unused-modules": [
65                         //      "error",
66                         //      {
67                         //              unusedExports: true,
69                         //              // When run via WebStorm, the root path against which these paths
70                         //              // are resolved is the path where this ESLint config file lies,
71                         //              // i.e. `src`. When run via the command line, it's usually the root
72                         //              // folder of the jQuery repository. This pattern intends to catch both.
73                         //              // Note that we cannot specify two patterns here:
74                         //              //     [ "src/*.js", "*.js" ]
75                         //              // as they're analyzed individually and the rule crashes if a pattern
76                         //              // cannot be matched.
77                         //              ignoreExports: [ "{src/,}*.js" ]
78                         //      }
79                         // ],
80                         indent: [
81                                 "error",
82                                 "tab",
83                                 {
84                                         outerIIFEBody: 0
85                                 }
86                         ],
87                         "one-var": [ "error", { var: "always" } ],
88                         strict: [ "error", "function" ]
89                 }
90         },
92         {
93                 files: [
94                         "src/wrapper.js",
95                         "src/wrapper-esm.js",
96                         "src/wrapper-factory.js",
97                         "src/wrapper-factory-esm.js"
98                 ],
99                 languageOptions: {
100                         globals: {
101                                 jQuery: false
102                         }
103                 },
104                 rules: {
105                         "no-unused-vars": "off",
106                         indent: [
107                                 "error",
108                                 "tab",
109                                 {
111                                         // This makes it so code within the wrapper is not indented.
112                                         ignoredNodes: [
113                                                 "Program > FunctionDeclaration > *"
114                                         ]
115                                 }
116                         ]
117                 }
118         },
120         {
121                 files: [
122                         "src/wrapper.js",
123                         "src/wrapper-factory.js"
124                 ],
125                 languageOptions: {
126                         sourceType: "script",
127                         globals: {
128                                 module: false
129                         }
130                 }
131         },
133         {
134                 files: [ "src/wrapper.js" ],
135                 rules: {
136                         indent: [
137                                 "error",
138                                 "tab",
139                                 {
141                                         // This makes it so code within the wrapper is not indented.
142                                         ignoredNodes: [
143                                                 "Program > ExpressionStatement > CallExpression > :last-child > *"
144                                         ]
145                                 }
146                         ]
147                 }
148         },
150         {
151                 files: [ "src/exports/amd.js" ],
152                 languageOptions: {
153                         globals: {
154                                 define: false
155                         }
156                 }
157         },
159         // Tests
160         {
161                 files: [
162                         "test/**"
163                 ],
164                 ignores: [
165                         "test/data/jquery-3.7.1.js",
166                         "test/data/badcall.js",
167                         "test/data/badjson.js",
168                         "test/data/support/csp.js",
169                         "test/data/support/getComputedSupport.js",
170                         "test/data/core/jquery-iterability-transpiled.js"
171                 ],
172                 languageOptions: {
173                         globals: {
174                                 ...globals.browser,
175                                 require: false,
176                                 Promise: false,
177                                 Symbol: false,
178                                 trustedTypes: false,
179                                 QUnit: false,
180                                 ajaxTest: false,
181                                 testIframe: false,
182                                 createDashboardXML: false,
183                                 createWithFriesXML: false,
184                                 createXMLFragment: false,
185                                 includesModule: false,
186                                 moduleTeardown: false,
187                                 url: false,
188                                 q: false,
189                                 jQuery: true,
190                                 sinon: true,
191                                 amdDefined: true,
192                                 fireNative: true,
193                                 Globals: true,
194                                 hasPHP: true,
195                                 isLocal: true,
196                                 supportjQuery: true,
197                                 originaljQuery: true,
198                                 $: true,
199                                 original$: true,
200                                 baseURL: true,
201                                 externalHost: true
202                         }
203                 },
204                 rules: {
205                         ...jqueryConfig.rules,
206                         strict: [ "error", "function" ],
208                         // See https://github.com/eslint/eslint/issues/2342
209                         "no-unused-vars": "off",
211                         // Too many errors
212                         "max-len": "off",
213                         camelcase: "off",
214                         "one-var": "off"
215                 }
216         },
218         {
219                 files: [
220                         "test/runner/**/*.js"
221                 ],
222                 languageOptions: {
223                         globals: {
224                                 ...globals.node
225                         },
226                         sourceType: "module"
227                 },
228                 rules: {
229                         ...jqueryConfig.rules
230                 }
231         },
233         {
234                 files: [ "test/runner/listeners.js" ],
235                 languageOptions: {
236                         ecmaVersion: 5,
237                         sourceType: "script"
238                 }
239         },
241         {
242                 files: [
243                         "test/data/testrunner.js",
244                         "test/data/core/jquery-iterability-transpiled-es6.js"
245                 ],
246                 languageOptions: {
247                         sourceType: "script"
248                 }
249         },
251         {
252                 files: [
253                         "test/unit/deferred.js"
254                 ],
255                 rules: {
257                         // Deferred tests set strict mode for certain tests
258                         strict: "off"
259                 }
260         },
262         {
263                 files: [
264                         "test/bundler_smoke_tests/**",
265                         "test/node_smoke_tests/**",
266                         "test/promises_aplus_adapters/**",
267                         "test/middleware-mockserver.cjs"
268                 ],
269                 languageOptions: {
270                         globals: {
271                                 ...globals.node,
272                                 ...globals.es2021
273                         }
274                 },
275                 rules: {
276                         strict: [ "error", "global" ]
277                 }
278         },
280         {
281                 files: [
282                         "build/**",
283                         "test/data/testinit.js"
284                 ],
285                 languageOptions: {
286                         globals: {
287                                 ...globals.node,
288                                 ...globals.es2021
289                         }
290                 },
291                 rules: {
292                         ...jqueryConfig.rules,
293                         strict: [ "error", "global" ]
294                 }
295         },
297         {
298                 files: [
299                         "build/**/*.js",
300                         "test/data/testinit.js"
301                 ],
302                 languageOptions: {
303                         sourceType: "commonjs"
304                 }
305         },
307         {
308                 files: [
309                         "dist/jquery.js",
310                         "dist/jquery.slim.js",
311                         "dist/jquery.factory.js",
312                         "dist/jquery.factory.slim.js",
313                         "dist-module/jquery.module.js",
314                         "dist-module/jquery.slim.module.js",
315                         "dist-module/jquery.factory.module.js",
316                         "dist-module/jquery.factory.slim.module.js"
317                 ],
319                 languageOptions: {
320                         globals: {
321                                 ...globals.es2021,
322                                 define: false,
323                                 module: false,
324                                 Symbol: false
325                         }
326                 }
327         },
329         {
330                 files: [
331                         "dist/jquery.bundler-require-wrapper.js",
332                         "dist/jquery.bundler-require-wrapper.slim.js",
333                         "dist-module/jquery.node-module-wrapper.js",
334                         "dist-module/jquery.node-module-wrapper.slim.js"
335                 ],
337                 languageOptions: {
338                         globals: {
339                                 ...globals.node,
340                                 ...globals.es2021,
341                                 define: false,
342                                 module: false,
343                                 Symbol: false
344                         }
345                 },
347                 rules: {
348                         ...jqueryConfig.rules,
350                         // That is okay for the built version
351                         "no-multiple-empty-lines": "off",
353                         // When custom compilation is used, the version string
354                         // can get large. Accept that in the built version.
355                         "max-len": "off",
356                         "one-var": "off"
357                 }
358         }