-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path.eslintrc.js
142 lines (135 loc) Β· 3.96 KB
/
.eslintrc.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
require("@nordcloud/eslint-config-pat/patch/modern-module-resolution");
/** @type {import("@types/eslint").Linter.Config} */
module.exports = {
extends: [
"@nordcloud/eslint-config-pat/profile/web-app",
"@nordcloud/eslint-config-pat/mixins/react",
],
parserOptions: { tsconfigRootDir: __dirname },
ignorePatterns: ["./*.js", "vitest.config.ts"],
settings: {
react: {
version: "detect", // React version. "detect" automatically picks the version you have installed.
},
},
overrides: [
{
files: ["**/*.{js,mjs}"],
parserOptions: {
sourceType: "module",
},
},
{
files: ["src/**/*.{ts,tsx}"],
rules: {
// Should be in sync with https://github.com/nordcloud/eslint-config-pat/blob/master/profile/_common.js#L463
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "default",
format: null,
},
// Ignore destructured names
{
selector: "variable",
types: ["array", "boolean", "function", "number", "string"],
modifiers: ["destructured"],
format: null,
},
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: [
"is",
"are",
"should",
"has",
"can",
"did",
"will",
"show",
"hide",
],
},
{
selector: "variable",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
filter: {
regex: "^(Component)$",
match: false,
},
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: ["function"],
format: ["camelCase", "PascalCase"],
leadingUnderscore: "forbid",
},
{
selector: ["typeProperty"],
format: ["camelCase"],
leadingUnderscore: "allowDouble",
filter: {
regex: "^(Component)$",
match: false,
},
},
{
selector: ["enumMember"],
format: ["PascalCase", "UPPER_CASE"],
},
{
selector: "enum",
format: ["PascalCase", "UPPER_CASE"],
},
],
},
},
{
// Declare an override that applies to TypeScript files only
files: [".storybook/**/*.{ts,tsx}"],
parser: "@typescript-eslint/parser",
parserOptions: {
// The "project" path is resolved relative to parserOptions.tsconfigRootDir.
// Your local .eslintrc.js must specify that parserOptions.tsconfigRootDir=__dirname.
tsconfigRootDir: __dirname + "/.storybook",
project: ["./tsconfig.json"],
// Allow parsing of newer ECMAScript constructs used in TypeScript source code. Although tsconfig.json
// may allow only a small subset of ES2018 features, this liberal setting ensures that ESLint will correctly
// parse whatever is encountered.
ecmaVersion: "latest",
sourceType: "module",
},
},
{
files: ["**/*.stories.tsx"],
rules: {
"react-hooks/rules-of-hooks": "off",
"no-alert": "off",
"unicorn/consistent-function-scoping": "off",
},
},
{
files: ["**/*.spec.{ts,tsx}"],
extends: [
"@nordcloud/eslint-config-pat/mixins/vitest",
"@nordcloud/eslint-config-pat/mixins/react-testing",
],
rules: {
"testing-library/no-node-access": "warn",
"testing-library/no-container": "warn",
},
},
],
};