Migrate eslint config to esmodules

And upgrade `@stylistic/eslint-plugin-js` to `4.0.x`

closes #5704
This commit is contained in:
Holger Jeromin 2025-02-19 09:44:40 +01:00
parent 79f5ccca31
commit 0f76726392
6 changed files with 19 additions and 23 deletions

View file

@ -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:

View file

@ -1,5 +1,5 @@
{
"eslint.options": {
"overrideConfigFile": "config/eslint.js"
"overrideConfigFile": "config/eslint.config.mjs"
}
}

View file

@ -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 }]

View file

@ -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

View file

@ -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"
}
}

View file

@ -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==