-
Notifications
You must be signed in to change notification settings - Fork 151
/
eslint.config.mjs
193 lines (192 loc) · 4.76 KB
/
eslint.config.mjs
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
import eslint from '@eslint/js'
import ts from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import prettier from 'eslint-config-prettier'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import testingLibrary from 'eslint-plugin-testing-library'
import jest from 'eslint-plugin-jest'
import globals from 'globals'
export default [
// Ignored dirs
{
ignores: ['dist/**/*', 'compiled/**/*', 'bundle/**/*']
},
// Temporary ignored dirs
// TODO: remove signers on rewrite
// TODO: remove e2e on rewrite
{
ignores: ['test/e2e/**/*', 'main/signers/**/*']
},
// All files
{
files: ['**/*.{js,mjs,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.es2021
}
},
rules: {
...eslint.configs.recommended.rules,
'no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
]
}
},
// Main process files and scripts
{
files: [
'*.{js,mjs,ts}',
'scripts/**/*.mjs',
'main/**/*.{js,ts}',
'build/**/*.js',
'resources/**/*.{js,ts}',
'test/*.js',
'test/__mocks__/*.js',
'test/main/**/*.{js,ts}'
],
ignores: ['resources/Components/**/*', 'resources/Hooks/**/*', 'resources/Native/**/*'],
languageOptions: {
globals: {
...globals.node
}
}
},
// Renderer process files
{
files: [
'app/**/*.js',
'main/dapps/server/inject/*.js',
'resources/keyboard/**/*.js',
'resources/Components/**/*.js',
'resources/Hooks/**/*.js',
'resources/Native/**/*.js',
'resources/bridge/index.js',
'resources/link/index.js',
'test/app/**/*.js',
'test/resources/Components/**/*.js',
'test/resources/Hooks/**/*.js',
'test/resources/Native/**/*.js'
],
languageOptions: {
globals: {
...globals.browser,
global: true
}
}
},
// Renderer entry points
{
files: ['app/*/index.js'],
languageOptions: {
globals: {
process: true
}
}
},
// TS files
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
project: './tsconfig.json'
}
},
plugins: {
'@typescript-eslint': ts
},
rules: {
...ts.configs['eslint-recommended'].rules,
...ts.configs.recommended.rules,
'no-undef': 'off', // redundant - TS will fail to compile with undefined vars
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
],
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }], // allow noop arrow functions, e.g. in a method signature for ensuring a parameter defaults to a function
'@typescript-eslint/prefer-namespace-keyword': 'off', // use ES module syntax instead of namespace
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }]
}
},
// React / JSX files
// TODO: simplify as '**/*.{jsx,tsx}'
{
files: [
'app/**/*.js',
'resources/Components/**/*.js',
'resources/Hooks/**/*.js',
'resources/Native/**/*.js',
'resources/svg/index.js',
'test/app/**/*.js',
'test/resources/Components/**/*.js',
'test/resources/Hooks/**/*.js',
'test/resources/Native/**/*.js',
'test/jest.svg.js'
],
plugins: {
react,
'react-hooks': reactHooks
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
},
settings: {
react: {
version: 'detect'
}
},
rules: {
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react/prop-types': 'off' // all type checking to be done in TS
}
},
// Test files
{
files: ['test/**/*.js', '**/__mocks__/**/*.js'],
plugins: {
jest
},
languageOptions: {
globals: {
...globals.jest
}
}
// TODO: enable jest rules
// rules: {
// ...jest.configs.recommended.rules
// }
},
// Components test files
{
files: ['test/app/**/*.js', 'test/resources/Components/**/*.js', 'app/**/__mocks__/**/*.js'],
plugins: {
'testing-library': testingLibrary
},
rules: {
...testingLibrary.configs.react.rules
}
},
// ensure all rules work with prettier
prettier
]