Skip to content

Commit 629480b

Browse files
committed
Migrate to ESLint v9.
1 parent fb431a9 commit 629480b

File tree

4 files changed

+71
-32
lines changed

4 files changed

+71
-32
lines changed

.eslintrc.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Updated the `package.json` field `repository` to conform to new npm requirements.
2020
- Updated GitHub Actions CI config:
2121
- Updated the tested Node.js versions to v18, v20.
22+
- Migrated to the ESLint v9 CLI and “flat” config.
2223
- Removed the Node.js CLI option `--unhandled-rejections=throw` in the package script `tests` as it’s now the default for all supported Node.js versions.
2324
- Omit unused catch bindings in the function `processRequest`.
2425

eslint.config.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// @ts-check
2+
3+
import eslintJs from "@eslint/js";
4+
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
5+
import globals from "globals";
6+
7+
/** @import { Linter } from "eslint" */
8+
9+
/**
10+
* Globs for ESM files.
11+
* @satisfies {Array<string>}
12+
*/
13+
const globsEsm = ["**/**.mjs"];
14+
15+
/**
16+
* Globs for CJS files.
17+
* @satisfies {Array<string>}
18+
*/
19+
const globsCjs = ["**/**.cjs", "**/**.js"];
20+
21+
/**
22+
* Globs for all JavaScript files.
23+
* @satisfies {Array<string>}
24+
*/
25+
const globsJs = [...globsEsm, ...globsCjs];
26+
27+
/**
28+
* ESLint configuration.
29+
* @satisfies {Array<Linter.FlatConfig>}
30+
*/
31+
const eslintConfig = [
32+
{
33+
files: globsJs,
34+
...eslintJs.configs.recommended,
35+
},
36+
{
37+
files: globsJs,
38+
rules: {
39+
"arrow-body-style": "error",
40+
"object-shorthand": "error",
41+
strict: "error",
42+
},
43+
},
44+
{
45+
files: globsEsm,
46+
languageOptions: {
47+
globals: globals.nodeBuiltin,
48+
},
49+
plugins: {
50+
"simple-import-sort": eslintPluginSimpleImportSort,
51+
},
52+
rules: {
53+
"simple-import-sort/imports": "error",
54+
"simple-import-sort/exports": "error",
55+
},
56+
},
57+
{
58+
files: globsCjs,
59+
languageOptions: {
60+
sourceType: "commonjs",
61+
globals: globals.node,
62+
},
63+
},
64+
];
65+
66+
export default eslintConfig;

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,22 @@
7373
"object-path": "^0.11.8"
7474
},
7575
"devDependencies": {
76+
"@eslint/js": "^9.11.1",
7677
"@types/express": "^5.0.0",
7778
"@types/koa": "^2.15.0",
7879
"coverage-node": "^8.0.0",
79-
"eslint": "^8.57.1",
80+
"eslint": "^9.11.1",
8081
"eslint-plugin-simple-import-sort": "^12.1.1",
8182
"express": "^5.0.0",
8283
"form-data-encoder": "^4.0.2",
84+
"globals": "^15.10.0",
8385
"graphql": "^16.9.0",
8486
"koa": "^2.15.3",
8587
"prettier": "^3.3.3",
8688
"typescript": "^5.6.2"
8789
},
8890
"scripts": {
89-
"eslint": "eslint .",
91+
"eslint": "eslint",
9092
"prettier": "prettier -c .",
9193
"types": "tsc -p jsconfig.json",
9294
"tests": "coverage-node --test-reporter=spec --test *.test.mjs",

0 commit comments

Comments
 (0)