diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2025-03-03 20:15:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-03 20:15:14 +0100 |
commit | 1da395de2e6759dfe9a7a199b03a39365e30f16c (patch) | |
tree | b597281911de6cde1682932ca9c242c0f8b5841d /eslint.config.mjs | |
parent | 302b488b9214e14830496578f7cf0aebcc33c132 (diff) | |
download | jquery-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
Diffstat (limited to 'eslint.config.mjs')
-rw-r--r-- | eslint.config.mjs | 162 |
1 files changed, 162 insertions, 0 deletions
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" ]` + } + } +]; |