forked from danskernesdigitalebibliotek/dpl-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc
163 lines (163 loc) · 4.09 KB
/
.eslintrc
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
"parser": "@typescript-eslint/parser",
"extends": [
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended",
"plugin:cypress/recommended"
],
"plugins": [
"no-only-tests"
],
"settings": {
"react": {
"version": "16.11.0"
},
// Since we use vitest alongside our production code we have to instruct eslint
// not to throw the import/no-extraneous-dependencies error when doing so.
"import/core-modules": [
"vitest"
]
},
"env": {
"browser": true,
"es6": true
},
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": false,
"ecmaFeatures": {
"jsx": true,
"globalReturn": false,
},
"project": "./tsconfig.json"
},
"rules": {
"prefer-arrow-callback": [
"error",
{
"allowNamedFunctions": false,
"allowUnboundThis": true
}
],
"no-param-reassign": [
"error",
{
"props": true,
"ignorePropertyModificationsFor": [
"state"
]
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"/**/*.dev.jsx",
"/**/*.dev.tsx",
"/**/*.test.js",
"/**/*.test.jsx",
"/**/*.test.ts",
"/**/*.test.tsx",
"vitest.config.ts",
"webpack.config.js",
"webpack.helpers.js",
"postcss.config.js",
"orval.config.ts",
"cypress/plugins/index.js",
"cypress/support/index.ts",
"scripts/postcss-node-sass.js",
"scripts/post-process-generated-graphql.ts",
"cypress/utils/graphql-test-utils.ts"
]
}
],
// We like to use arrow function syntax also for functional components.
"react/function-component-definition": "off",
// No complaints about missing trailing comma
"@typescript-eslint/comma-dangle": "off",
"react-hooks/exhaustive-deps": [
"warn",
{
"additionalHooks": "useDeepCompareEffect"
}
],
"no-only-tests/no-only-tests": "warn"
},
"overrides": [
{
"files": [
"*.js",
"*.jsx"
],
"rules": {
// These rules were triggered on the former non-typescript codebase.
// We are planning to use only ts/tsx in the future
// Therefor we can seperate them by only being ignored on js/jsx files.
// Start - ddb-react former code
"react/jsx-no-bind": "off",
"react/function-component-definition": "off",
"react/forbid-prop-types": "off",
"react/destructuring-assignment": "off",
"@typescript-eslint/return-await": "off",
"no-param-reassign": "off",
"@typescript-eslint/no-var-requires": "off"
// End - ddb-react former code
}
},
{
"files": [
"*.tsx",
"*.ts"
],
"rules": {
// We do not use prop-types in ts.
"react/prop-types": "off",
"react/require-default-props": "off",
"react/no-unused-prop-types": "off",
"no-underscore-dangle": [
"error",
{
"allow": [
"__typename"
]
}
],
"react/forbid-elements": [
1,
{
"forbid": [
{
"element": "main",
"message": "dpl-cms provide a <main> to render react in, therefore you must use <section> to avoid duplicate main"
}
]
}
]
}
},
{
"files": [
"*.dev.jsx",
"*.dev.tsx"
],
"rules": {
// We need a simple way of passing args in stories via object spreading.
"react/jsx-props-no-spreading": "off",
}
},
{
"files": [
"*.entry.tsx"
],
"rules": {
// Since we use High Order Functional Component in entries for text props
// and want to show the props being used we disable this rule.
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}