Skip to content

Commit 8ddd04a

Browse files
authored
[AP-5405] Bump node to 22 & eslint version to 9 (#742)
bump node & eslint versions
1 parent ad81056 commit 8ddd04a

File tree

8 files changed

+5112
-4465
lines changed

8 files changed

+5112
-4465
lines changed

.eslintignore

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

.eslintrc.js

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

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.20.6
1+
v22.14.0

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist
44
node_modules
55
storybook-static
66
tsconfig.json
7+
eslint.config.mjs

eslint.config.mjs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import tsParser from "@typescript-eslint/parser";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import js from "@eslint/js";
6+
import { FlatCompat } from "@eslint/eslintrc";
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all
14+
});
15+
16+
export default defineConfig([globalIgnores([
17+
"./*.js",
18+
"**/vitest.config.ts",
19+
"!**/.*",
20+
"**/build",
21+
"**/coverage",
22+
"**/dist",
23+
"**/node_modules",
24+
"**/storybook-static",
25+
]), {
26+
extends: compat.extends(
27+
"@nordcloud/eslint-config-pat/profile/web-app",
28+
"@nordcloud/eslint-config-pat/mixins/react",
29+
),
30+
31+
languageOptions: {
32+
ecmaVersion: 5,
33+
sourceType: "script",
34+
35+
parserOptions: {
36+
tsconfigRootDir: __dirname,
37+
},
38+
},
39+
40+
settings: {
41+
react: {
42+
version: "detect", // React version. "detect" automatically picks the version you have installed.
43+
},
44+
},
45+
}, {
46+
files: ["**/*.{js,mjs}"],
47+
48+
languageOptions: {
49+
ecmaVersion: 5,
50+
sourceType: "module",
51+
},
52+
}, {
53+
files: ["src/**/*.{ts,tsx}"],
54+
55+
rules: {
56+
// Should be in sync with https://github.com/nordcloud/eslint-config-pat/blob/master/profile/_common.js#L463
57+
"@typescript-eslint/naming-convention": ["warn", {
58+
selector: "default",
59+
format: null,
60+
// Ignore destructured names
61+
}, {
62+
selector: "variable",
63+
types: ["array", "boolean", "function", "number", "string"],
64+
modifiers: ["destructured"],
65+
format: null,
66+
}, {
67+
selector: "variable",
68+
types: ["boolean"],
69+
format: ["PascalCase"],
70+
prefix: ["is", "are", "should", "has", "can", "did", "will", "show", "hide"],
71+
}, {
72+
selector: "variable",
73+
format: ["camelCase", "UPPER_CASE", "PascalCase"],
74+
}, {
75+
selector: "parameter",
76+
format: ["camelCase"],
77+
leadingUnderscore: "allow",
78+
79+
filter: {
80+
regex: "^(Component)$",
81+
match: false,
82+
},
83+
}, {
84+
selector: "memberLike",
85+
modifiers: ["private"],
86+
format: ["camelCase"],
87+
leadingUnderscore: "require",
88+
}, {
89+
selector: ["function"],
90+
format: ["camelCase", "PascalCase"],
91+
leadingUnderscore: "forbid",
92+
}, {
93+
selector: ["typeProperty"],
94+
format: ["camelCase"],
95+
leadingUnderscore: "allowDouble",
96+
97+
filter: {
98+
regex: "^(Component)$",
99+
match: false,
100+
},
101+
}, {
102+
selector: ["enumMember"],
103+
format: ["PascalCase", "UPPER_CASE"],
104+
}, {
105+
selector: "enum",
106+
format: ["PascalCase", "UPPER_CASE"],
107+
}],
108+
},
109+
}, {
110+
// Declare an override that applies to TypeScript files only
111+
files: [".storybook/**/*.{ts,tsx}"],
112+
113+
languageOptions: {
114+
parser: tsParser,
115+
// Allow parsing of newer ECMAScript constructs used in TypeScript source code. Although tsconfig.json
116+
// may allow only a small subset of ES2018 features, this liberal setting ensures that ESLint will correctly
117+
// parse whatever is encountered.
118+
ecmaVersion: "latest",
119+
sourceType: "module",
120+
121+
// The "project" path is resolved relative to parserOptions.tsconfigRootDir.
122+
// Your local .eslintrc.js must specify that parserOptions.tsconfigRootDir=__dirname.
123+
parserOptions: {
124+
tsconfigRootDir: __dirname + "/.storybook",
125+
project: ["./tsconfig.json"],
126+
},
127+
},
128+
}, {
129+
files: ["**/*.stories.tsx"],
130+
131+
rules: {
132+
"react-hooks/rules-of-hooks": "off",
133+
"no-alert": "off",
134+
"unicorn/consistent-function-scoping": "off",
135+
},
136+
}, {
137+
files: ["**/*.spec.{ts,tsx}"],
138+
139+
extends: compat.extends(
140+
"@nordcloud/eslint-config-pat/mixins/vitest",
141+
"@nordcloud/eslint-config-pat/mixins/react-testing",
142+
),
143+
144+
rules: {
145+
"testing-library/no-node-access": "warn",
146+
"testing-library/no-container": "warn",
147+
},
148+
// .eslintignore
149+
}, {
150+
// Note: there should be no other properties in this object
151+
ignores: [
152+
"eslint.config.mjs",
153+
"**/.*",
154+
"build",
155+
"coverage",
156+
"dist",
157+
"node_modules",
158+
"storybook-static"
159+
],
160+
},]);

0 commit comments

Comments
 (0)