Skip to content

Commit 1da395d

Browse files
authored
Build: Update ESLint to v9, migrate to flat config, lint dist files
Dist files linting is limited to checking if they're proper ES5. Closes gh-2336
1 parent 302b488 commit 1da395d

16 files changed

+181
-100
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/node.js.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ jobs:
4949
- name: Install npm dependencies
5050
run: npm install
5151

52-
- name: Lint
53-
run: npm run lint
54-
5552
- name: Build
5653
run: npm run build
5754

55+
# Lint must happen after build as we lint generated files.
56+
- name: Lint
57+
run: npm run lint
58+
5859
- name: Test
5960
run: |
6061
npm run test:unit -- \

Gruntfile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,12 @@ grunt.initConfig( {
204204
"ui/**/*.js",
205205
"!ui/vendor/**/*.js",
206206
"Gruntfile.js",
207+
"dist/jquery-ui.js",
208+
"dist/jquery-ui.min.js",
207209
"build/**/*.js",
208210
"tests/unit/**/*.js",
209211
"tests/lib/**/*.js",
212+
"!tests/lib/vendor/**/*.js",
210213
"demos/**/*.js"
211214
]
212215
},
@@ -401,7 +404,7 @@ grunt.registerTask( "lint", [
401404
"htmllint"
402405
] );
403406
grunt.registerTask( "build", [ "requirejs", "concat", "minify:main" ] );
404-
grunt.registerTask( "default", [ "lint", "build" ] );
407+
grunt.registerTask( "default", [ "build", "lint" ] );
405408
grunt.registerTask( "sizer", [ "requirejs:js", "minify:main", "compare_size:all" ] );
406409
grunt.registerTask( "sizer_all", [ "requirejs:js", "minify", "compare_size" ] );
407410

demos/.eslintrc.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import jqueryConfig from "eslint-config-jquery";
2+
import globals from "globals";
3+
4+
export default [
5+
{
6+
ignores: [
7+
"dist/**/*",
8+
"!dist/jquery-ui.js",
9+
"!dist/jquery-ui.min.js",
10+
"external/**/*",
11+
"tests/lib/vendor/**/*",
12+
"ui/vendor/**/*"
13+
]
14+
},
15+
16+
{
17+
ignores: [ "dist/**/*" ],
18+
rules: {
19+
...jqueryConfig.rules,
20+
"no-unused-vars": [
21+
"error",
22+
{
23+
argsIgnorePattern: "^_",
24+
caughtErrorsIgnorePattern: "^_"
25+
}
26+
]
27+
}
28+
},
29+
30+
{
31+
files: [ "Gruntfile.js" ],
32+
languageOptions: {
33+
ecmaVersion: "latest",
34+
sourceType: "commonjs",
35+
globals: {
36+
...globals.node
37+
}
38+
},
39+
rules: {
40+
strict: [ "error", "global" ]
41+
}
42+
},
43+
44+
{
45+
files: [ "eslint.config.mjs" ],
46+
languageOptions: {
47+
ecmaVersion: "latest",
48+
sourceType: "module",
49+
globals: {
50+
...globals.node
51+
}
52+
},
53+
rules: {
54+
strict: [ "error", "global" ]
55+
}
56+
},
57+
58+
// Source, demos
59+
{
60+
files: [ "ui/**/*.js", "demos/**/*.js" ],
61+
languageOptions: {
62+
ecmaVersion: 5,
63+
sourceType: "script",
64+
globals: {
65+
...globals.browser,
66+
...globals.jquery,
67+
define: false,
68+
Globalize: false
69+
}
70+
},
71+
rules: {
72+
strict: [ "error", "function" ],
73+
74+
// The following rule is relaxed due to too many violations:
75+
"no-unused-vars": [
76+
"error",
77+
{
78+
args: "after-used",
79+
argsIgnorePattern: "^_",
80+
caughtErrorsIgnorePattern: "^_"
81+
}
82+
],
83+
84+
// Too many violations:
85+
camelcase: "off",
86+
"no-nested-ternary": "off"
87+
}
88+
},
89+
{
90+
files: [ "ui/i18n/**/*.js" ],
91+
rules: {
92+
93+
// We want to keep all the strings in separate single lines
94+
"max-len": "off"
95+
}
96+
},
97+
98+
// Dist files
99+
// For dist files, we don't include any jQuery rules on purpose.
100+
// We just want to make sure the files are correct ES5.
101+
{
102+
files: [ "dist/jquery-ui.js", "dist/jquery-ui.min.js" ],
103+
languageOptions: {
104+
ecmaVersion: 5,
105+
sourceType: "script"
106+
},
107+
linterOptions: {
108+
reportUnusedDisableDirectives: "off"
109+
}
110+
},
111+
112+
// Build
113+
{
114+
files: [ "build/**/*.js" ],
115+
languageOptions: {
116+
ecmaVersion: "latest",
117+
sourceType: "commonjs",
118+
globals: {
119+
...globals.node
120+
}
121+
},
122+
rules: {
123+
"no-implicit-globals": "error",
124+
strict: [ "error", "global" ]
125+
}
126+
},
127+
128+
// Demos
129+
{
130+
files: [ "demos/**/*.js" ],
131+
languageOptions: {
132+
globals: {
133+
require: true
134+
}
135+
}
136+
},
137+
138+
// Tests
139+
{
140+
files: [ "tests/**/*.js" ],
141+
languageOptions: {
142+
ecmaVersion: 5,
143+
sourceType: "script",
144+
globals: {
145+
...globals.browser,
146+
...globals.jquery,
147+
define: false,
148+
Globalize: false,
149+
QUnit: false,
150+
require: true,
151+
requirejs: true
152+
}
153+
},
154+
"rules": {
155+
156+
// Too many violations:
157+
"max-len": "off",
158+
"no-unused-vars": "off",
159+
strict: "off" // ideally, `[ "error", "function" ]`
160+
}
161+
}
162+
];

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@
5858
"@swc/core": "1.11.5",
5959
"commitplease": "3.2.0",
6060
"eslint-config-jquery": "3.0.2",
61+
"globals": "16.0.0",
6162
"grunt": "1.6.1",
6263
"grunt-bowercopy": "1.2.5",
6364
"grunt-compare-size": "0.4.2",
6465
"grunt-contrib-concat": "2.1.0",
6566
"grunt-contrib-csslint": "2.0.0",
6667
"grunt-contrib-requirejs": "1.0.0",
67-
"grunt-eslint": "24.0.1",
68+
"grunt-eslint": "25.0.0",
6869
"grunt-git-authors": "3.2.0",
6970
"grunt-html": "17.1.0",
7071
"jquery-test-runner": "0.2.5",

ui/.eslintrc.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

ui/effect.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
//>>label: Effects Core
1111
//>>group: Effects
12-
/* eslint-disable max-len */
1312
//>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
14-
/* eslint-enable max-len */
1513
//>>docs: https://api.jqueryui.com/category/effects-core/
1614
//>>demos: https://jqueryui.com/effect/
1715

@@ -320,7 +318,7 @@ if ( $.uiBackCompat === true ) {
320318
try {
321319
// eslint-disable-next-line no-unused-expressions
322320
active.id;
323-
} catch ( e ) {
321+
} catch ( _e ) {
324322
active = document.body;
325323
}
326324

ui/effects/effect-explode.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
//>>label: Explode Effect
1111
//>>group: Effects
12-
/* eslint-disable max-len */
1312
//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
14-
/* eslint-enable max-len */
1513
//>>docs: https://api.jqueryui.com/explode-effect/
1614
//>>demos: https://jqueryui.com/effect/
1715

0 commit comments

Comments
 (0)