-
Notifications
You must be signed in to change notification settings - Fork 121
/
eslint.config.js
215 lines (203 loc) · 5.62 KB
/
eslint.config.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import stylisticTs from '@stylistic/eslint-plugin'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import typescriptParser from '@typescript-eslint/parser'
import exportDefaultIdentifier from 'eslint-plugin-export-default-identifier'
import importPlugin from 'eslint-plugin-import'
import jsdoc from 'eslint-plugin-jsdoc'
import prettier from 'eslint-plugin-prettier'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
const commonSettings = {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
}
const commonPlugins = {
'@stylistic/ts': stylisticTs,
'export-default-identifier': exportDefaultIdentifier,
jsdoc,
react,
'react-refresh': reactRefresh,
prettier,
'@typescript-eslint': typescriptEslint,
import: importPlugin,
'react-hooks': reactHooks,
}
const commonRules = {
'no-irregular-whitespace': 'error',
'no-extra-semi': 'error',
'prefer-const': 'error',
'no-loop-func': 'warn',
'no-useless-constructor': 'warn',
'react/display-name': 'error',
'no-restricted-properties': [
'error',
{
object: 'window',
property: 'getSelection',
message:
'Please import the appropriate helper function from /src/device/selection.ts to access the browser selection. This is done to abstract the browser selection API from the rest of the codebase.',
},
],
'export-default-identifier/export-default-identifier': 'off',
'import/prefer-default-export': [
'error',
{
// any: Any exporting file must contain a default export.
// single: When there is only a single export from a module, prefer using default export over named export.
target: 'any',
},
],
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/check-syntax': 'error',
'jsdoc/check-types': 'error',
'jsdoc/implements-on-classes': 'error',
'jsdoc/no-types': 'error',
// Disable until performance issue is solved.
// https://github.com/gajus/eslint-plugin-jsdoc/issues/1334
// 'jsdoc/no-undefined-types': 2,
'jsdoc/check-tag-names': [
'error',
{
definedTags: ['packageDocumentation'],
},
],
'jsdoc/require-description-complete-sentence': [
'error',
{
abbreviations: ['e.g.', 'i.e.'],
},
],
'jsdoc/require-jsdoc': [
'error',
{
contexts: ['VariableDeclarator > ArrowFunctionExpression'],
enableFixer: false,
require: {
ClassDeclaration: true,
ClassExpression: true,
},
},
],
// jsx-a11y
'jsx-a11y/anchor-is-valid': 'off',
// react
'react/jsx-curly-spacing': 'error',
'react/jsx-equals-spacing': 'error',
'react/react-in-jsx-scope': 'off',
'react/jsx-tag-spacing': ['error', { beforeSelfClosing: 'allow' }],
'react/no-children-prop': 'off',
'react/no-unescaped-entities': 'off',
'react/prop-types': 'off',
// react-hooks
'react-hooks/exhaustive-deps': 'error',
// prettier
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
}
export default [
{
ignores: [
'node_modules/**',
'**/styled-system/*',
'**/ios/*',
'**/android/**',
'**/build/*',
'**/docs/*',
'**/functions/*',
'**/scripts/*',
],
},
{
languageOptions: {
...commonSettings,
},
plugins: {
...commonPlugins,
},
rules: {
...commonRules,
},
settings: {
react: {
version: 'detect',
},
},
},
// Overrides for specific folders
{
files: ['src/e2e/**', '**/__tests__/*'],
rules: {
'no-restricted-properties': 'off',
'jsdoc/check-tag-names': 'off',
},
},
// Overrides for TypeScript files
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaFeatures: { jsx: true },
project: ['./tsconfig.json', './tsconfig.eslint.json'],
},
},
plugins: {
'@typescript-eslint': typescriptEslint,
},
rules: {
...typescriptEslint.configs['eslint-recommended'].rules,
...typescriptEslint.configs.recommended.rules,
semi: ['error', 'never'],
'no-extra-parens': 'off',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'@stylistic/ts/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'none',
},
},
],
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-unused-vars': ['error', { args: 'none', caughtErrors: 'none', varsIgnorePattern: '^_' }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/array-type': 'error',
// jsx
'jsx-quotes': ['error', 'prefer-single'],
// react-refresh
'react-refresh/only-export-components': 'error',
},
},
{
files: ['./src/**/*.ts', './src/**/*.tsx'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
},
},
},
{
files: ['./src/e2e/**/*.ts'],
rules: {
'jsdoc/check-tag-names': 'off',
},
},
]