Skip to content

Commit 1d51f40

Browse files
authored
Upgrade ESLint, rework config, split out Prettier (#333)
1 parent 44ad81f commit 1d51f40

File tree

7 files changed

+709
-743
lines changed

7 files changed

+709
-743
lines changed

.github/workflows/test-javascript.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ jobs:
3636
cache-dependency-path: javascript/package-lock.json
3737
- run: npm install-test
3838
working-directory: javascript
39-
- run: npm run eslint
39+
- run: npm run lint
4040
working-directory: javascript

javascript/.eslintrc.json

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

javascript/eslint.config.mjs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
2+
import _import from "eslint-plugin-import";
3+
import simpleImportSort from "eslint-plugin-simple-import-sort";
4+
import n from "eslint-plugin-n";
5+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
6+
import globals from "globals";
7+
import tsParser from "@typescript-eslint/parser";
8+
import path from "node:path";
9+
import { fileURLToPath } from "node:url";
10+
import js from "@eslint/js";
11+
import { FlatCompat } from "@eslint/eslintrc";
12+
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
15+
const compat = new FlatCompat({
16+
baseDirectory: __dirname,
17+
recommendedConfig: js.configs.recommended,
18+
allConfig: js.configs.all
19+
});
20+
21+
export default [...fixupConfigRules(compat.extends(
22+
"eslint:recommended",
23+
"plugin:import/typescript",
24+
"plugin:@typescript-eslint/eslint-recommended",
25+
"plugin:@typescript-eslint/recommended",
26+
)), {
27+
plugins: {
28+
import: fixupPluginRules(_import),
29+
"simple-import-sort": simpleImportSort,
30+
n,
31+
"@typescript-eslint": fixupPluginRules(typescriptEslint),
32+
},
33+
34+
languageOptions: {
35+
globals: {
36+
...globals.browser,
37+
...globals.node,
38+
},
39+
40+
parser: tsParser,
41+
ecmaVersion: 5,
42+
sourceType: "module",
43+
44+
parserOptions: {
45+
project: "tsconfig.json",
46+
},
47+
},
48+
49+
rules: {
50+
"import/no-cycle": "error",
51+
"n/no-extraneous-import": "error",
52+
"@typescript-eslint/ban-ts-ignore": "off",
53+
"@typescript-eslint/ban-ts-comment": "off",
54+
"@typescript-eslint/explicit-module-boundary-types": "off",
55+
"@typescript-eslint/explicit-function-return-type": "off",
56+
"@typescript-eslint/no-use-before-define": "off",
57+
"@typescript-eslint/interface-name-prefix": "off",
58+
"@typescript-eslint/member-delimiter-style": "off",
59+
"@typescript-eslint/no-explicit-any": "error",
60+
"@typescript-eslint/no-non-null-assertion": "error",
61+
"simple-import-sort/imports": "error",
62+
"simple-import-sort/exports": "error",
63+
},
64+
}, {
65+
files: ["test/**"],
66+
67+
rules: {
68+
"@typescript-eslint/no-non-null-assertion": "off",
69+
},
70+
}];

0 commit comments

Comments
 (0)