-
Notifications
You must be signed in to change notification settings - Fork 72
/
.eslintrc.cjs
101 lines (97 loc) · 2.46 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const path = require("path");
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:security/recommended-legacy",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
overrides: [
getCdkOverrides("cdk/lib"),
getCdkOverrides("cdk/custom-auth"),
getCdkOverrides("end-to-end-example/cdk"),
getClientOverrides("client"),
getClientOverrides("end-to-end-example/client"),
],
plugins: ["@typescript-eslint", "header", "import"],
root: true,
};
function rules() {
return {
"@typescript-eslint/no-non-null-assertion": "off",
"require-await": "off",
"@typescript-eslint/require-await": "off",
"header/header": ["error", path.join(__dirname, "header.js")],
"restrict-template-expressions": "off",
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowNullish: true },
],
"import/extensions": ["error", "ignorePackages"],
};
}
function getCdkOverrides(basedir) {
return {
files: `${basedir}/**/*`,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
project: [`${basedir}/tsconfig.json`],
},
extends: [
"eslint:recommended",
"plugin:security/recommended-legacy",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
rules: rules(),
};
}
function getClientOverrides(basedir) {
return {
env: {
browser: true,
es2021: true,
node: true,
},
files: "client/**/*",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
project: ["client/tsconfig.json"],
},
extends: [
"eslint:recommended",
"plugin:security/recommended-legacy",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
settings: {
react: {
version: "detect",
},
},
rules: {
...rules(),
"react/react-in-jsx-scope": "off",
"no-restricted-globals": [
"error",
"window",
"document",
"history",
"location",
"crypto",
"fetch",
],
},
plugins: ["react", "@typescript-eslint", "header", "import"],
};
}