From a2533b0d253e13151c331fc884721341a416efa8 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Sat, 13 Jan 2024 17:19:21 +0900 Subject: [PATCH 1/9] ci: test with ESLint 9 & manage testing ESLint versions with CI --- .github/workflows/actions.yml | 7 +++++ test-packages/test.sh | 55 ++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 494a658d..8f012a11 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -27,6 +27,13 @@ jobs: - 16 - 18 - 20 + eslint-version: + - 7 + - 8 + - 9 + + env: + ESLINT_VERSION: ${{ matrix.eslint-version }} steps: - uses: actions/checkout@v3 diff --git a/test-packages/test.sh b/test-packages/test.sh index 6166c038..e8305806 100755 --- a/test-packages/test.sh +++ b/test-packages/test.sh @@ -6,6 +6,11 @@ TEST_PKGS_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" PROJECT_ROOT="$(realpath "${TEST_PKGS_DIR}/..")" TMP="$(mktemp --directory)" +# To run tests on local machine +if [[ -z "${ESLINT_VERSION:-}" ]]; then + ESLINT_VERSION=9 +fi + cd "${PROJECT_ROOT}" PACKAGE="$(npm pack .)" @@ -15,31 +20,29 @@ git clean -Xd --force # If you test without copying, test package is affected by node_modules in the project root cp --recursive "${TEST_PKGS_DIR}" "${TMP}/" -for ESLINT_VERSION in "7" "8"; do - for PKGDIR in $(find "${TMP}/test-packages/success/" -maxdepth 1 -type d ! -path "${TMP}/test-packages/success/"); do - cd "${PKGDIR}" - npm install - npm install --save-dev "eslint@${ESLINT_VERSION}" "${PROJECT_ROOT}/${PACKAGE}" - npm run lint - done - - for PKGDIR in $(find "${TMP}/test-packages/failure/" -maxdepth 1 -type d ! -path "${TMP}/test-packages/failure/"); do - cd "${PKGDIR}" - npm install - npm install --save-dev "eslint@${ESLINT_VERSION}" "${PROJECT_ROOT}/${PACKAGE}" - - if [[ "${PKGDIR}" = "${TMP}/test-packages/failure/missing-ts-eslint" ]]; then - # skip if Node.js version == 14.x - if [[ -n "$(node --version | grep '^v14\.')" ]]; then - continue - fi - - if [[ -z "$((npm run lint 2>&1) | grep "eslint-plugin-editorconfig requires typescript and @typescript-eslint/eslint-plugin to lint \*.ts files. Run \`npm install typescript @typescript-eslint/eslint-plugin\`.")" ]]; then - echo "Error message is not shown properly when @typescript-eslint/eslint-plugin is missing" >&2 - echo "ESLint's error message:" - npm run lint - exit 1 - fi +for PKGDIR in $(find "${TMP}/test-packages/success/" -maxdepth 1 -type d ! -path "${TMP}/test-packages/success/"); do + cd "${PKGDIR}" + npm install + npm install --save-dev "eslint@${ESLINT_VERSION}" "${PROJECT_ROOT}/${PACKAGE}" + npm run lint +done + +for PKGDIR in $(find "${TMP}/test-packages/failure/" -maxdepth 1 -type d ! -path "${TMP}/test-packages/failure/"); do + cd "${PKGDIR}" + npm install + npm install --save-dev "eslint@${ESLINT_VERSION}" "${PROJECT_ROOT}/${PACKAGE}" + + if [[ "${PKGDIR}" = "${TMP}/test-packages/failure/missing-ts-eslint" ]]; then + # skip if Node.js version == 14.x + if [[ -n "$(node --version | grep '^v14\.')" ]]; then + continue + fi + + if [[ -z "$((npm run lint 2>&1) | grep "eslint-plugin-editorconfig requires typescript and @typescript-eslint/eslint-plugin to lint \*.ts files. Run \`npm install typescript @typescript-eslint/eslint-plugin\`.")" ]]; then + echo "Error message is not shown properly when @typescript-eslint/eslint-plugin is missing" >&2 + echo "ESLint's error message:" + npm run lint + exit 1 fi - done + fi done From 372f4e533c239e66e38e2cce34730000aa7cc210 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 08:34:55 +0900 Subject: [PATCH 2/9] ci: remove support for Node.js <= 16 & add Node.js 21 --- .github/workflows/actions.yml | 3 +-- test-packages/test.sh | 20 ++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 8f012a11..1af51636 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -23,10 +23,9 @@ jobs: strategy: matrix: node-version: - - 14 - - 16 - 18 - 20 + - 21 eslint-version: - 7 - 8 diff --git a/test-packages/test.sh b/test-packages/test.sh index e8305806..b1c4e0ec 100755 --- a/test-packages/test.sh +++ b/test-packages/test.sh @@ -32,17 +32,13 @@ for PKGDIR in $(find "${TMP}/test-packages/failure/" -maxdepth 1 -type d ! -path npm install npm install --save-dev "eslint@${ESLINT_VERSION}" "${PROJECT_ROOT}/${PACKAGE}" - if [[ "${PKGDIR}" = "${TMP}/test-packages/failure/missing-ts-eslint" ]]; then - # skip if Node.js version == 14.x - if [[ -n "$(node --version | grep '^v14\.')" ]]; then - continue - fi - - if [[ -z "$((npm run lint 2>&1) | grep "eslint-plugin-editorconfig requires typescript and @typescript-eslint/eslint-plugin to lint \*.ts files. Run \`npm install typescript @typescript-eslint/eslint-plugin\`.")" ]]; then - echo "Error message is not shown properly when @typescript-eslint/eslint-plugin is missing" >&2 - echo "ESLint's error message:" - npm run lint - exit 1 - fi + if \ + [[ "${PKGDIR}" = "${TMP}/test-packages/failure/missing-ts-eslint" ]] && \ + [[ -z "$((npm run lint 2>&1) | grep "eslint-plugin-editorconfig requires typescript and @typescript-eslint/eslint-plugin to lint \*.ts files. Run \`npm install typescript @typescript-eslint/eslint-plugin\`.")" ]] + then + echo "Error message is not shown properly when @typescript-eslint/eslint-plugin is missing" >&2 + echo "ESLint's error message:" + npm run lint + exit 1 fi done From bf502e09693cd760957631b806b559b9318e0703 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 08:42:20 +0900 Subject: [PATCH 3/9] test: temporarily disable flat config on test --- test-packages/success/base-rules-conflict/package.json | 2 +- test-packages/success/js/package.json | 2 +- test-packages/success/ts/package.json | 2 +- test-packages/test.sh | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test-packages/success/base-rules-conflict/package.json b/test-packages/success/base-rules-conflict/package.json index c8fa2c5c..b6ba1b51 100644 --- a/test-packages/success/base-rules-conflict/package.json +++ b/test-packages/success/base-rules-conflict/package.json @@ -7,7 +7,7 @@ "private": true, "main": "main.js", "scripts": { - "lint": "eslint . --ext=.js,.ts", + "lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext=.js,.ts", "test": "npm run lint" } } diff --git a/test-packages/success/js/package.json b/test-packages/success/js/package.json index f99b1df2..3e97e443 100644 --- a/test-packages/success/js/package.json +++ b/test-packages/success/js/package.json @@ -7,7 +7,7 @@ "private": true, "main": "main.js", "scripts": { - "lint": "eslint .", + "lint": "ESLINT_USE_FLAT_CONFIG=false eslint .", "test": "npm run lint" } } diff --git a/test-packages/success/ts/package.json b/test-packages/success/ts/package.json index 888b6a25..bf6362e8 100644 --- a/test-packages/success/ts/package.json +++ b/test-packages/success/ts/package.json @@ -7,7 +7,7 @@ "private": true, "main": "main.js", "scripts": { - "lint": "eslint . --ext=.js,.ts", + "lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext=.js,.ts", "test": "npm run lint" }, "devDependencies": { diff --git a/test-packages/test.sh b/test-packages/test.sh index b1c4e0ec..59a160e6 100755 --- a/test-packages/test.sh +++ b/test-packages/test.sh @@ -2,6 +2,9 @@ set -eux +# Until this plugin supports flat config, test with legacy .eslintrc.* +export ESLINT_USE_FLAT_CONFIG=false + TEST_PKGS_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" PROJECT_ROOT="$(realpath "${TEST_PKGS_DIR}/..")" TMP="$(mktemp --directory)" From 42f708139564d3df6cb90ddf184f66a8e640bc30 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 13:13:42 +0900 Subject: [PATCH 4/9] chore: disable flat config on lint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c2d052f..e5bfdb91 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "main.js", "scripts": { "test": "./test-packages/test.sh && mocha --reporter dot tests/lib/**/*.js", - "lint": "eslint .", + "lint": "ESLINT_USE_FLAT_CONFIG=false eslint .", "release": "npm publish . --access public" }, "keywords": [ From f3dec1e9e01bfb6ad2bc15223c4612c5604b4bbd Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 08:45:38 +0900 Subject: [PATCH 5/9] doc: add instruction for unfinished flat config support --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e6147bc..9844f01f 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,13 @@ $ npm install --save-dev @typescript-eslint/eslint-plugin ### eslint.config.* (Flat Config) -Unfortunately, eslint-plugin-editorconfig does not work properly with Flat Config for now, even if you use `@eslint/eslintrc` for compatibility. -Please wait for the next version. +Unfortunately, eslint-plugin-editorconfig does not work properly with Flat Config for now, even if you use `@eslint/eslintrc` for compatibility. +Please wait for the next version. +If you use ESLint v9, set the `ESLINT_USE_FLAT_CONFIG` environment variable to `false` to use traditional .eslintrc.\*. + +```shell +ESLINT_USE_FLAT_CONFIG=false npx eslint --ext=.js,.ts . +``` ### .eslintrc.* From 27247838a2030c25f27b7ccbdd57e1091de05e68 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 08:51:41 +0900 Subject: [PATCH 6/9] chore: upgrade bundled ESLint version to v9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e5bfdb91..9f4bd619 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "homepage": "https://github.com/phanect/eslint-plugin-editorconfig", "dependencies": { "editorconfig": "^1.0.2", - "eslint": "^8.40.0", + "eslint": "^9.0.0", "klona": "^2.0.4" }, "devDependencies": { From f5c32475492dc30cd56128e183a60a8104042298 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 08:57:08 +0900 Subject: [PATCH 7/9] chore: upgrade other package versions --- package.json | 4 ++-- test-packages/success/ts/package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9f4bd619..783a2216 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "klona": "^2.0.4" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.0.0", - "@typescript-eslint/parser": "^5.0.0", + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", "eslint-config-phanective": "latest", "mocha": "^10.2.0" }, diff --git a/test-packages/success/ts/package.json b/test-packages/success/ts/package.json index bf6362e8..06840074 100644 --- a/test-packages/success/ts/package.json +++ b/test-packages/success/ts/package.json @@ -11,8 +11,8 @@ "test": "npm run lint" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.0.0", - "@typescript-eslint/parser": "^5.0.0", - "typescript": "^4.1.3" + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", + "typescript": "^5.0.0" } } From 0d394f7978b8c293f6b2cf4f64730f8fef7f201b Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 08:57:37 +0900 Subject: [PATCH 8/9] chore: remove unnecessary dependency mocha --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 783a2216..1b013ed8 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,7 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.6.0", "@typescript-eslint/parser": "^7.6.0", - "eslint-config-phanective": "latest", - "mocha": "^10.2.0" + "eslint-config-phanective": "latest" }, "engines": { "node": ">=14", From 9bb264e1db0b84953a70e799de7f222e0d23e6e8 Mon Sep 17 00:00:00 2001 From: Jumpei Ogawa Date: Wed, 10 Apr 2024 09:04:18 +0900 Subject: [PATCH 9/9] chore: enable `legacy-peer-deps` as a workaround --- .npmrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.npmrc b/.npmrc index 43c97e71..74215ad6 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,6 @@ package-lock=false + +# As of 2024/04/10, typescript-eslint does not support ESLint v9 yet. +# Therefore, you cannnot install `eslint` and `@typescript-eslint/*` packages at the same time for now. +# Until typescript-eslint support ESLint v9, enable legacy-peer-deps. +legacy-peer-deps=true