From 0f767263926ef8d3e8bd01aee7dce3e34c6cad94 Mon Sep 17 00:00:00 2001 From: Holger Jeromin Date: Wed, 19 Feb 2025 09:44:40 +0100 Subject: [PATCH] Migrate eslint config to esmodules And upgrade `@stylistic/eslint-plugin-js` to `4.0.x` closes #5704 --- .overcommit.yml | 2 +- .vscode/settings.json | 2 +- config/{eslint.js => eslint.config.mjs} | 18 +++++++----------- lib/tasks/eslint.rake | 2 +- package.json | 6 +++--- yarn.lock | 12 ++++++------ 6 files changed, 19 insertions(+), 23 deletions(-) rename config/{eslint.js => eslint.config.mjs} (94%) diff --git a/.overcommit.yml b/.overcommit.yml index eab8eb2ae..18bd5851f 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -22,7 +22,7 @@ PreCommit: enabled: true EsLint: enabled: true - command: ["bin/yarn", "eslint", "-c", "config/eslint.js"] + command: ["bin/yarn", "eslint", "-c", "config/eslint.config.mjs"] exclude: - vendor/**/*.js RailsSchemaUpToDate: diff --git a/.vscode/settings.json b/.vscode/settings.json index 8a3d341d4..3545f0727 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "eslint.options": { - "overrideConfigFile": "config/eslint.js" + "overrideConfigFile": "config/eslint.config.mjs" } } diff --git a/config/eslint.js b/config/eslint.config.mjs similarity index 94% rename from config/eslint.js rename to config/eslint.config.mjs index 6055634aa..d695f0131 100644 --- a/config/eslint.js +++ b/config/eslint.config.mjs @@ -1,9 +1,9 @@ -const globals = require("globals"); -const js = require("@eslint/js"); -const erb = require("eslint-plugin-erb"); -const stylisticJs = require("@stylistic/eslint-plugin-js"); +import globals from "globals"; +import js from "@eslint/js"; +import erb from "eslint-plugin-erb"; +import stylisticJs from "@stylistic/eslint-plugin-js"; -module.exports = [ +export default [ js.configs.recommended, erb.configs.recommended, { @@ -164,13 +164,9 @@ module.exports = [ } }, { - files: ["config/eslint.js"], + files: ["config/eslint.config.mjs"], languageOptions: { - ecmaVersion: 2019, - sourceType: "commonjs", - globals: { - ...globals.commonjs - } + sourceType: "module" }, rules: { "sort-keys": ["error", "asc", { minKeys: 5 }] diff --git a/lib/tasks/eslint.rake b/lib/tasks/eslint.rake index 17f28a4e9..8a8d7c8a4 100644 --- a/lib/tasks/eslint.rake +++ b/lib/tasks/eslint.rake @@ -5,7 +5,7 @@ def yarn_path end def config_file - Rails.root.join("config/eslint.js").to_s + Rails.root.join("config/eslint.config.mjs").to_s end namespace "eslint" do diff --git a/package.json b/package.json index f4eacf962..f8eac3db9 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ "osm-community-index": "^5.2.0" }, "devDependencies": { - "@types/jquery": "^3.5.32", - "@types/leaflet": "^1.9.16", + "@types/jquery": "^3.5.0", + "@types/leaflet": "^1.9.0", "eslint": "^9.0.0", "eslint-plugin-erb": "^2.1.0", - "@stylistic/eslint-plugin-js": "^3.0.0", + "@stylistic/eslint-plugin-js": "^4.0.0", "eslint-formatter-compact": "^8.40.0" } } diff --git a/yarn.lock b/yarn.lock index 10dff4023..71a706e45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -103,10 +103,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.1.tgz#9a96ce501bc62df46c4031fbd970e3cc6b10f07b" integrity sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA== -"@stylistic/eslint-plugin-js@^3.0.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-3.1.0.tgz#b36292b09bd810ea1b34e0720512f137335ef745" - integrity sha512-lQktsOiCr8S6StG29C5fzXYxLOD6ID1rp4j6TRS+E/qY1xd59Fm7dy5qm9UauJIEoSTlYx6yGsCHYh5UkgXPyg== +"@stylistic/eslint-plugin-js@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-4.0.1.tgz#c55e59ad2f00914f9eb103ba9e7be00aff7715dd" + integrity sha512-2EGKM6WHnZSidWKCu6ePJCqdpgWiEU1Bt26ktWEfTpCmRP+2vRQ6ViK8X6DLwu4+F0zPLy/Txe2HhI3qJFUvqA== dependencies: eslint-visitor-keys "^4.2.0" espree "^10.3.0" @@ -121,7 +121,7 @@ resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a" integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg== -"@types/jquery@^3.5.32": +"@types/jquery@^3.5.0": version "3.5.32" resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.5.32.tgz#3eb0da20611b92c7c49ebed6163b52a4fdc57def" integrity sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ== @@ -133,7 +133,7 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== -"@types/leaflet@^1.9.16": +"@types/leaflet@^1.9.0": version "1.9.16" resolved "https://registry.yarnpkg.com/@types/leaflet/-/leaflet-1.9.16.tgz#3e3abc103e106523cde01625057e2294f332ec3b" integrity sha512-wzZoyySUxkgMZ0ihJ7IaUIblG8Rdc8AbbZKLneyn+QjYsj5q1QU7TEKYqwTr10BGSzY5LI7tJk9Ifo+mEjdFRw== -- 2.39.5