diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 494a658d..1af51636 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -23,10 +23,16 @@ jobs: strategy: matrix: node-version: - - 14 - - 16 - 18 - 20 + - 21 + eslint-version: + - 7 + - 8 + - 9 + + env: + ESLINT_VERSION: ${{ matrix.eslint-version }} steps: - uses: actions/checkout@v3 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 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.* diff --git a/package.json b/package.json index 4c2d052f..1b013ed8 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": [ @@ -25,14 +25,13 @@ "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": { - "@typescript-eslint/eslint-plugin": "^5.0.0", - "@typescript-eslint/parser": "^5.0.0", - "eslint-config-phanective": "latest", - "mocha": "^10.2.0" + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", + "eslint-config-phanective": "latest" }, "engines": { "node": ">=14", 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..06840074 100644 --- a/test-packages/success/ts/package.json +++ b/test-packages/success/ts/package.json @@ -7,12 +7,12 @@ "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": { - "@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" } } diff --git a/test-packages/test.sh b/test-packages/test.sh index 6166c038..59a160e6 100755 --- a/test-packages/test.sh +++ b/test-packages/test.sh @@ -2,10 +2,18 @@ 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)" +# To run tests on local machine +if [[ -z "${ESLINT_VERSION:-}" ]]; then + ESLINT_VERSION=9 +fi + cd "${PROJECT_ROOT}" PACKAGE="$(npm pack .)" @@ -15,31 +23,25 @@ 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}" +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" ]] && \ + [[ -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 - 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 - fi - done + exit 1 + fi done