Skip to content

Build: Update ESLint to v9, migrate to flat config, lint dist files #2336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

21 changes: 0 additions & 21 deletions .eslintrc.json

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- \
Expand Down
5 changes: 4 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
Expand Down Expand Up @@ -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" ] );

Expand Down
9 changes: 0 additions & 9 deletions demos/.eslintrc.json

This file was deleted.

162 changes: 162 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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" ]`
}
}
];
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
42 changes: 0 additions & 42 deletions ui/.eslintrc.json

This file was deleted.

4 changes: 1 addition & 3 deletions ui/effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down Expand Up @@ -320,7 +318,7 @@ if ( $.uiBackCompat === true ) {
try {
// eslint-disable-next-line no-unused-expressions
active.id;
} catch ( e ) {
} catch ( _e ) {
active = document.body;
}

Expand Down
2 changes: 0 additions & 2 deletions ui/effects/effect-explode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
2 changes: 0 additions & 2 deletions ui/widgets/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions ui/widgets/datepicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable max-len, camelcase */
/* eslint-disable max-len */
/*!
* jQuery UI Datepicker @VERSION
* https://jqueryui.com
Expand Down Expand Up @@ -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";
}
},
Expand Down Expand Up @@ -768,7 +768,7 @@ $.extend( Datepicker.prototype, {
$.datepicker._updateAlternate( inst );
$.datepicker._updateDatepicker( inst );
}
} catch ( err ) {
} catch ( _err ) {
}
}
return true;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1569,7 +1569,7 @@ $.extend( Datepicker.prototype, {
try {
return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
offset, $.datepicker._getFormatConfig( inst ) );
} catch ( e ) {
} catch ( _e ) {

// Ignore
}
Expand Down
2 changes: 0 additions & 2 deletions ui/widgets/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ui/widgets/resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading
Loading