aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2025-03-03 20:15:14 +0100
committerGitHub <noreply@github.com>2025-03-03 20:15:14 +0100
commit1da395de2e6759dfe9a7a199b03a39365e30f16c (patch)
treeb597281911de6cde1682932ca9c242c0f8b5841d
parent302b488b9214e14830496578f7cf0aebcc33c132 (diff)
downloadjquery-ui-1da395de2e6759dfe9a7a199b03a39365e30f16c.tar.gz
jquery-ui-1da395de2e6759dfe9a7a199b03a39365e30f16c.zip
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
-rw-r--r--.eslintignore4
-rw-r--r--.eslintrc.json21
-rw-r--r--.github/workflows/node.js.yml7
-rw-r--r--Gruntfile.js5
-rw-r--r--demos/.eslintrc.json9
-rw-r--r--eslint.config.mjs162
-rw-r--r--package.json3
-rw-r--r--ui/.eslintrc.json42
-rw-r--r--ui/effect.js4
-rw-r--r--ui/effects/effect-explode.js2
-rw-r--r--ui/widgets/accordion.js2
-rw-r--r--ui/widgets/datepicker.js10
-rw-r--r--ui/widgets/progressbar.js2
-rw-r--r--ui/widgets/resizable.js2
-rw-r--r--ui/widgets/selectmenu.js2
-rw-r--r--ui/widgets/tabs.js4
16 files changed, 181 insertions, 100 deletions
diff --git a/.eslintignore b/.eslintignore
deleted file mode 100644
index 5e992599f..000000000
--- a/.eslintignore
+++ /dev/null
@@ -1,4 +0,0 @@
-dist/**/*
-external/**/*
-tests/lib/vendor/**/*
-ui/vendor/**/*
diff --git a/.eslintrc.json b/.eslintrc.json
deleted file mode 100644
index e7d67eb0e..000000000
--- a/.eslintrc.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "root": true,
-
- "extends": "jquery",
-
- // Uncomment to find useless comment disable directives
- // "reportUnusedDisableDirectives": true,
-
- "parserOptions": {
- "ecmaVersion": 2018
- },
-
- "env": {
- "es6": true,
- "node": true
- },
-
- "rules": {
- "strict": [ "error", "global" ]
- }
-}
diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml
index 6279223a3..eef7c86e7 100644
--- a/.github/workflows/node.js.yml
+++ b/.github/workflows/node.js.yml
@@ -49,12 +49,13 @@ jobs:
- name: Install npm dependencies
run: npm install
- - name: Lint
- run: npm run lint
-
- name: Build
run: npm run build
+ # Lint must happen after build as we lint generated files.
+ - name: Lint
+ run: npm run lint
+
- name: Test
run: |
npm run test:unit -- \
diff --git a/Gruntfile.js b/Gruntfile.js
index cc532b6e9..bbb71d33e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -204,9 +204,12 @@ grunt.initConfig( {
"ui/**/*.js",
"!ui/vendor/**/*.js",
"Gruntfile.js",
+ "dist/jquery-ui.js",
+ "dist/jquery-ui.min.js",
"build/**/*.js",
"tests/unit/**/*.js",
"tests/lib/**/*.js",
+ "!tests/lib/vendor/**/*.js",
"demos/**/*.js"
]
},
@@ -401,7 +404,7 @@ grunt.registerTask( "lint", [
"htmllint"
] );
grunt.registerTask( "build", [ "requirejs", "concat", "minify:main" ] );
-grunt.registerTask( "default", [ "lint", "build" ] );
+grunt.registerTask( "default", [ "build", "lint" ] );
grunt.registerTask( "sizer", [ "requirejs:js", "minify:main", "compare_size:all" ] );
grunt.registerTask( "sizer_all", [ "requirejs:js", "minify", "compare_size" ] );
diff --git a/demos/.eslintrc.json b/demos/.eslintrc.json
deleted file mode 100644
index 805ec8eb2..000000000
--- a/demos/.eslintrc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "root": true,
-
- "extends": "../ui/.eslintrc.json",
-
- "globals": {
- "require": true
- }
-}
diff --git a/eslint.config.mjs b/eslint.config.mjs
new file mode 100644
index 000000000..4fb03f6b3
--- /dev/null
+++ b/eslint.config.mjs
@@ -0,0 +1,162 @@
+import jqueryConfig from "eslint-config-jquery";
+import globals from "globals";
+
+export default [
+ {
+ ignores: [
+ "dist/**/*",
+ "!dist/jquery-ui.js",
+ "!dist/jquery-ui.min.js",
+ "external/**/*",
+ "tests/lib/vendor/**/*",
+ "ui/vendor/**/*"
+ ]
+ },
+
+ {
+ ignores: [ "dist/**/*" ],
+ rules: {
+ ...jqueryConfig.rules,
+ "no-unused-vars": [
+ "error",
+ {
+ argsIgnorePattern: "^_",
+ caughtErrorsIgnorePattern: "^_"
+ }
+ ]
+ }
+ },
+
+ {
+ files: [ "Gruntfile.js" ],
+ languageOptions: {
+ ecmaVersion: "latest",
+ sourceType: "commonjs",
+ globals: {
+ ...globals.node
+ }
+ },
+ rules: {
+ strict: [ "error", "global" ]
+ }
+ },
+
+ {
+ files: [ "eslint.config.mjs" ],
+ languageOptions: {
+ ecmaVersion: "latest",
+ sourceType: "module",
+ globals: {
+ ...globals.node
+ }
+ },
+ rules: {
+ strict: [ "error", "global" ]
+ }
+ },
+
+ // Source, demos
+ {
+ files: [ "ui/**/*.js", "demos/**/*.js" ],
+ languageOptions: {
+ ecmaVersion: 5,
+ sourceType: "script",
+ globals: {
+ ...globals.browser,
+ ...globals.jquery,
+ define: false,
+ Globalize: false
+ }
+ },
+ rules: {
+ strict: [ "error", "function" ],
+
+ // The following rule is relaxed due to too many violations:
+ "no-unused-vars": [
+ "error",
+ {
+ args: "after-used",
+ argsIgnorePattern: "^_",
+ caughtErrorsIgnorePattern: "^_"
+ }
+ ],
+
+ // Too many violations:
+ camelcase: "off",
+ "no-nested-ternary": "off"
+ }
+ },
+ {
+ files: [ "ui/i18n/**/*.js" ],
+ rules: {
+
+ // We want to keep all the strings in separate single lines
+ "max-len": "off"
+ }
+ },
+
+ // Dist files
+ // For dist files, we don't include any jQuery rules on purpose.
+ // We just want to make sure the files are correct ES5.
+ {
+ files: [ "dist/jquery-ui.js", "dist/jquery-ui.min.js" ],
+ languageOptions: {
+ ecmaVersion: 5,
+ sourceType: "script"
+ },
+ linterOptions: {
+ reportUnusedDisableDirectives: "off"
+ }
+ },
+
+ // Build
+ {
+ files: [ "build/**/*.js" ],
+ languageOptions: {
+ ecmaVersion: "latest",
+ sourceType: "commonjs",
+ globals: {
+ ...globals.node
+ }
+ },
+ rules: {
+ "no-implicit-globals": "error",
+ strict: [ "error", "global" ]
+ }
+ },
+
+ // Demos
+ {
+ files: [ "demos/**/*.js" ],
+ languageOptions: {
+ globals: {
+ require: true
+ }
+ }
+ },
+
+ // Tests
+ {
+ files: [ "tests/**/*.js" ],
+ languageOptions: {
+ ecmaVersion: 5,
+ sourceType: "script",
+ globals: {
+ ...globals.browser,
+ ...globals.jquery,
+ define: false,
+ Globalize: false,
+ QUnit: false,
+ require: true,
+ requirejs: true
+ }
+ },
+ "rules": {
+
+ // Too many violations:
+ "max-len": "off",
+ "no-unused-vars": "off",
+ strict: "off" // ideally, `[ "error", "function" ]`
+ }
+ }
+];
diff --git a/package.json b/package.json
index c34bef799..00f9e07fe 100644
--- a/package.json
+++ b/package.json
@@ -58,13 +58,14 @@
"@swc/core": "1.11.5",
"commitplease": "3.2.0",
"eslint-config-jquery": "3.0.2",
+ "globals": "16.0.0",
"grunt": "1.6.1",
"grunt-bowercopy": "1.2.5",
"grunt-compare-size": "0.4.2",
"grunt-contrib-concat": "2.1.0",
"grunt-contrib-csslint": "2.0.0",
"grunt-contrib-requirejs": "1.0.0",
- "grunt-eslint": "24.0.1",
+ "grunt-eslint": "25.0.0",
"grunt-git-authors": "3.2.0",
"grunt-html": "17.1.0",
"jquery-test-runner": "0.2.5",
diff --git a/ui/.eslintrc.json b/ui/.eslintrc.json
deleted file mode 100644
index eaba81af2..000000000
--- a/ui/.eslintrc.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "root": true,
-
- "extends": "jquery",
-
- "parserOptions": {
- "ecmaVersion": 5
- },
-
- "env": {
- "browser": true,
- "jquery": true,
- "node": false
- },
-
- "rules": {
- "strict": [ "error", "function" ],
-
- // The following rule is relaxed due to too many violations:
- "no-unused-vars": [ "error", { "vars": "all", "args": "after-used" } ],
-
- // Too many violations:
- "camelcase": "off",
- "no-nested-ternary": "off"
- },
-
- "globals": {
- "define": false,
- "Globalize": false
- },
-
- "overrides": [
- {
- "files": [ "i18n/**/*.js" ],
- "rules": {
-
- // We want to keep all the strings in separate single lines
- "max-len": "off"
- }
- }
- ]
-}
diff --git a/ui/effect.js b/ui/effect.js
index bbbb733c3..cb9ab8043 100644
--- a/ui/effect.js
+++ b/ui/effect.js
@@ -9,9 +9,7 @@
//>>label: Effects Core
//>>group: Effects
-/* eslint-disable max-len */
//>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
-/* eslint-enable max-len */
//>>docs: https://api.jqueryui.com/category/effects-core/
//>>demos: https://jqueryui.com/effect/
@@ -320,7 +318,7 @@ if ( $.uiBackCompat === true ) {
try {
// eslint-disable-next-line no-unused-expressions
active.id;
- } catch ( e ) {
+ } catch ( _e ) {
active = document.body;
}
diff --git a/ui/effects/effect-explode.js b/ui/effects/effect-explode.js
index ed40833a8..da38b4d55 100644
--- a/ui/effects/effect-explode.js
+++ b/ui/effects/effect-explode.js
@@ -9,9 +9,7 @@
//>>label: Explode Effect
//>>group: Effects
-/* eslint-disable max-len */
//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
-/* eslint-enable max-len */
//>>docs: https://api.jqueryui.com/explode-effect/
//>>demos: https://jqueryui.com/effect/
diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js
index ff6e4631d..43a50db83 100644
--- a/ui/widgets/accordion.js
+++ b/ui/widgets/accordion.js
@@ -9,9 +9,7 @@
//>>label: Accordion
//>>group: Widgets
-/* eslint-disable max-len */
//>>description: Displays collapsible content panels for presenting information in a limited amount of space.
-/* eslint-enable max-len */
//>>docs: https://api.jqueryui.com/accordion/
//>>demos: https://jqueryui.com/accordion/
//>>css.structure: ../../themes/base/core.css
diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js
index 323723b89..029f255e8 100644
--- a/ui/widgets/datepicker.js
+++ b/ui/widgets/datepicker.js
@@ -1,4 +1,4 @@
-/* eslint-disable max-len, camelcase */
+/* eslint-disable max-len */
/*!
* jQuery UI Datepicker @VERSION
* https://jqueryui.com
@@ -535,7 +535,7 @@ $.extend( Datepicker.prototype, {
_getInst: function( target ) {
try {
return $.data( target, "datepicker" );
- } catch ( err ) {
+ } catch ( _err ) {
throw "Missing instance data for this datepicker";
}
},
@@ -768,7 +768,7 @@ $.extend( Datepicker.prototype, {
$.datepicker._updateAlternate( inst );
$.datepicker._updateDatepicker( inst );
}
- } catch ( err ) {
+ } catch ( _err ) {
}
}
return true;
@@ -1540,7 +1540,7 @@ $.extend( Datepicker.prototype, {
try {
date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
- } catch ( event ) {
+ } catch ( _err ) {
dates = ( noDefault ? "" : dates );
}
inst.selectedDay = date.getDate();
@@ -1569,7 +1569,7 @@ $.extend( Datepicker.prototype, {
try {
return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
offset, $.datepicker._getFormatConfig( inst ) );
- } catch ( e ) {
+ } catch ( _e ) {
// Ignore
}
diff --git a/ui/widgets/progressbar.js b/ui/widgets/progressbar.js
index 20e96440a..ad5366ade 100644
--- a/ui/widgets/progressbar.js
+++ b/ui/widgets/progressbar.js
@@ -9,9 +9,7 @@
//>>label: Progressbar
//>>group: Widgets
-/* eslint-disable max-len */
//>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
-/* eslint-enable max-len */
//>>docs: https://api.jqueryui.com/progressbar/
//>>demos: https://jqueryui.com/progressbar/
//>>css.structure: ../../themes/base/core.css
diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js
index 6f1e0ebde..012315283 100644
--- a/ui/widgets/resizable.js
+++ b/ui/widgets/resizable.js
@@ -104,7 +104,7 @@ $.widget( "ui.resizable", $.ui.mouse, {
el[ scroll ] = 1;
has = ( el[ scroll ] > 0 );
el[ scroll ] = 0;
- } catch ( e ) {
+ } catch ( _e ) {
// `el` might be a string, then setting `scroll` will throw
// an error in strict mode; ignore it.
diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js
index f1b48fa60..749e33491 100644
--- a/ui/widgets/selectmenu.js
+++ b/ui/widgets/selectmenu.js
@@ -9,9 +9,7 @@
//>>label: Selectmenu
//>>group: Widgets
-/* eslint-disable max-len */
//>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
-/* eslint-enable max-len */
//>>docs: https://api.jqueryui.com/selectmenu/
//>>demos: https://jqueryui.com/selectmenu/
//>>css.structure: ../../themes/base/core.css
diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js
index 7b7907c32..49468feb3 100644
--- a/ui/widgets/tabs.js
+++ b/ui/widgets/tabs.js
@@ -73,10 +73,10 @@ $.widget( "ui.tabs", {
// Decoding may throw an error if the URL isn't UTF-8 (#9518)
try {
anchorUrl = decodeURIComponent( anchorUrl );
- } catch ( error ) {}
+ } catch ( _error ) {}
try {
locationUrl = decodeURIComponent( locationUrl );
- } catch ( error ) {}
+ } catch ( _error ) {}
return anchor.hash.length > 1 && anchorUrl === locationUrl;
};