Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test-packages/success/base-rules-conflict/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion test-packages/success/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"main": "main.js",
"scripts": {
"lint": "eslint .",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint .",
"test": "npm run lint"
}
}
8 changes: 4 additions & 4 deletions test-packages/success/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
54 changes: 28 additions & 26 deletions test-packages/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .)"

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