Tests: replace dead links in qunit fixture
[jquery.git] / eslint.config.js
blobceb943dbbea9e61d5ee3c4436faceed19a23bf1a
1 import jqueryConfig from "eslint-config-jquery";
2 import importPlugin from "eslint-plugin-import";
3 import globals from "globals";
5 export default [
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 "test/data/jquery-*.js"
19 // Source
21 files: [ "src/**" ],
22 plugins: {
23 import: importPlugin
25 languageOptions: {
26 ecmaVersion: 2015,
28 // The browser env is not enabled on purpose so that code takes
29 // all browser-only globals from window instead of assuming
30 // they're available as globals. This makes it possible to use
31 // jQuery with tools like jsdom which provide a custom window
32 // implementation.
33 globals: {
34 window: false
37 rules: {
38 ...jqueryConfig.rules,
39 "import/extensions": [ "error", "always" ],
40 "import/no-cycle": "error",
42 // TODO: Enable this rule when eslint-plugin-import supports
43 // it when using flat config.
44 // See https://github.com/import-js/eslint-plugin-import/issues/2556
46 // "import/no-unused-modules": [
47 // "error",
48 // {
49 // unusedExports: true,
51 // // When run via WebStorm, the root path against which these paths
52 // // are resolved is the path where this ESLint config file lies,
53 // // i.e. `src`. When run via the command line, it's usually the root
54 // // folder of the jQuery repository. This pattern intends to catch both.
55 // // Note that we cannot specify two patterns here:
56 // // [ "src/*.js", "*.js" ]
57 // // as they're analyzed individually and the rule crashes if a pattern
58 // // cannot be matched.
59 // ignoreExports: [ "{src/,}*.js" ]
60 // }
61 // ],
62 indent: [
63 "error",
64 "tab",
66 outerIIFEBody: 0
69 "no-implicit-globals": "error",
70 "no-unused-vars": [
71 "error",
72 { caughtErrorsIgnorePattern: "^_" }
74 "one-var": [ "error", { var: "always" } ],
75 strict: [ "error", "function" ]
80 files: [
81 "src/wrapper.js",
82 "src/wrapper-esm.js",
83 "src/wrapper-factory.js",
84 "src/wrapper-factory-esm.js"
86 languageOptions: {
87 globals: {
88 jQuery: false
91 rules: {
92 "no-unused-vars": "off",
93 indent: [
94 "error",
95 "tab",
98 // This makes it so code within the wrapper is not indented.
99 ignoredNodes: [
100 "Program > FunctionDeclaration > *"
108 files: [
109 "src/wrapper.js",
110 "src/wrapper-factory.js"
112 languageOptions: {
113 sourceType: "script",
114 globals: {
115 module: false
121 files: [ "src/wrapper.js" ],
122 rules: {
123 indent: [
124 "error",
125 "tab",
128 // This makes it so code within the wrapper is not indented.
129 ignoredNodes: [
130 "Program > ExpressionStatement > CallExpression > :last-child > *"
138 files: [ "src/exports/amd.js" ],
139 languageOptions: {
140 globals: {
141 define: false
146 // Tests
148 files: [
149 "test/*",
150 "test/data/**",
151 "test/integration/**",
152 "test/unit/**"
154 ignores: [
155 "test/data/badcall.js",
156 "test/data/badjson.js",
157 "test/data/support/csp.js",
158 "test/data/support/getComputedSupport.js",
159 "test/data/core/jquery-iterability-transpiled.js"
161 languageOptions: {
162 ecmaVersion: 2015,
163 sourceType: "script",
164 globals: {
165 ...globals.browser,
166 require: false,
167 trustedTypes: false,
168 QUnit: false,
169 ajaxTest: false,
170 testIframe: false,
171 createDashboardXML: false,
172 createWithFriesXML: false,
173 createXMLFragment: false,
174 includesModule: false,
175 moduleTeardown: false,
176 url: false,
177 q: false,
178 jQuery: false,
179 $: false,
180 sinon: false,
181 amdDefined: false,
182 fireNative: false,
183 Globals: false,
184 hasPHP: false,
185 isLocal: false,
186 supportjQuery: false,
187 originaljQuery: false,
188 original$: false,
189 baseURL: false,
190 externalHost: false
193 rules: {
194 ...jqueryConfig.rules,
196 "no-unused-vars": [
197 "error",
198 { args: "after-used", argsIgnorePattern: "^_" }
201 // Too many errors
202 "max-len": "off",
203 camelcase: "off"
208 files: [
209 "test/unit/core.js"
211 rules: {
213 // Core has several cases where unused vars are expected
214 "no-unused-vars": "off"
219 files: [
220 "test/runner/**/*.js"
222 languageOptions: {
223 ecmaVersion: "latest",
224 globals: {
225 ...globals.node
228 rules: {
229 ...jqueryConfig.rules
234 files: [ "test/runner/listeners.js" ],
235 languageOptions: {
236 ecmaVersion: 5,
237 sourceType: "script",
238 globals: {
239 ...globals.browser,
240 QUnit: false,
241 Symbol: false
247 files: [
248 "test/data/testinit.js",
249 "test/data/testrunner.js",
250 "test/data/core/jquery-iterability-transpiled-es6.js"
252 languageOptions: {
253 ecmaVersion: 2015,
254 sourceType: "script",
255 globals: {
256 ...globals.browser
259 rules: {
260 ...jqueryConfig.rules,
261 strict: [ "error", "function" ]
266 files: [
267 "test/data/testinit.js"
269 rules: {
270 strict: [ "error", "global" ]
275 files: [
276 "test/unit/deferred.js"
278 rules: {
280 // Deferred tests set strict mode for certain tests
281 strict: "off"
286 files: [
287 "eslint.config.js",
288 ".release-it.cjs",
289 "build/**",
290 "test/node_smoke_tests/**",
291 "test/bundler_smoke_tests/**/*",
292 "test/promises_aplus_adapters/**",
293 "test/middleware-mockserver.cjs"
295 languageOptions: {
296 ecmaVersion: "latest",
297 globals: {
298 ...globals.browser,
299 ...globals.node
302 rules: {
303 ...jqueryConfig.rules,
304 "no-implicit-globals": "error",
305 "no-unused-vars": [
306 "error",
307 { caughtErrorsIgnorePattern: "^_" }
309 strict: [ "error", "global" ]
314 files: [
315 "dist/jquery.js",
316 "dist/jquery.slim.js",
317 "dist/jquery.factory.js",
318 "dist/jquery.factory.slim.js",
319 "dist-module/jquery.module.js",
320 "dist-module/jquery.slim.module.js",
321 "dist-module/jquery.factory.module.js",
322 "dist-module/jquery.factory.slim.module.js",
323 "dist/wrappers/*.js",
324 "dist-module/wrappers/*.js"
326 languageOptions: {
327 ecmaVersion: 2015,
328 globals: {
329 define: false,
330 module: false,
331 Symbol: false,
332 window: false
335 rules: {
336 ...jqueryConfig.rules,
338 "no-implicit-globals": "error",
340 // That is okay for the built version
341 "no-multiple-empty-lines": "off",
343 "no-unused-vars": [
344 "error",
345 { caughtErrorsIgnorePattern: "^_" }
348 // When custom compilation is used, the version string
349 // can get large. Accept that in the built version.
350 "max-len": "off",
351 "one-var": "off"
356 files: [
357 "dist/jquery.slim.js",
358 "dist/jquery.factory.slim.js",
359 "dist-module/jquery.slim.module.js",
360 "dist-module/jquery.factory.slim.module.js"
362 rules: {
364 // Rollup is now smart enough to remove the use
365 // of parameters if the argument is not passed
366 // anywhere in the build.
367 // The removal of effects in the slim build
368 // results in some parameters not being used,
369 // which can be safely ignored.
370 "no-unused-vars": [
371 "error",
372 { args: "none" }
378 files: [
379 "src/wrapper.js",
380 "src/wrapper-factory.js",
381 "dist/jquery.factory.js",
382 "dist/jquery.factory.slim.js",
383 "test/middleware-mockserver.cjs"
385 rules: {
386 "no-implicit-globals": "off"
391 files: [
392 "dist/**"
394 languageOptions: {
395 ecmaVersion: 5,
396 sourceType: "script"
401 files: [
402 "dist-module/**"
404 languageOptions: {
405 ecmaVersion: 2015,
406 sourceType: "module"
411 files: [
412 "dist/wrappers/*.js"
414 languageOptions: {
415 ecmaVersion: 2015,
416 sourceType: "commonjs"