forked from qinheqing/browser-extension-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
238 lines (227 loc) · 7.23 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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true,
es2017: true,
},
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2017,
ecmaFeatures: {
experimentalObjectRestSpread: true,
impliedStrict: true,
modules: true,
blockBindings: true,
arrowFunctions: true,
objectLiteralShorthandMethods: true,
objectLiteralShorthandProperties: true,
templateStrings: true,
classes: true,
jsx: true,
},
},
ignorePatterns: [
'!.eslintrc.js',
'!.prettierrc.js',
'node_modules/**',
'dist/**',
'builds/**',
'test-*/**',
'docs/**',
'coverage/',
'app/scripts/chromereload.js',
'development/chromereload.js',
'app/vendor/**',
'app/vendor-js/**',
'src/vendors/**',
'test/e2e/send-eth-with-private-key-test/**',
'nyc_output/**',
'.vscode/**',
'src/**/*.d.ts',
],
extends: [
'./development/eslint/eslint-config.js',
'./development/eslint/eslint-config-nodejs.js',
'./development/eslint/eslint-config-mocha.js',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
plugins: ['@babel', 'react', 'import', 'prettier', 'jsx-a11y'],
globals: {
document: 'readonly',
window: 'readonly',
},
rules: {
// Prettier changes and reasoning
'no-tabs': 'off',
'import/no-anonymous-default-export': 'off',
'prettier/prettier': 'error',
'no-unused-vars': 'warn',
'no-debugger': 'warn',
'react/prop-types': 'warn',
'yield-star-spacing': 'off',
'import/no-named-as-default-member': 'off',
// Our eslint config has the default setting for this as error. This
// include beforeBlockComment: true, but in order to match the prettier
// spec you have to enable before and after blocks, objects and arrays
// https://github.com/prettier/eslint-config-prettier#lines-around-comment
'lines-around-comment': [
'error',
{
beforeBlockComment: true,
afterLineComment: false,
allowBlockStart: true,
allowBlockEnd: true,
allowObjectStart: true,
allowObjectEnd: true,
allowArrayStart: true,
allowArrayEnd: true,
},
],
// Prettier has some opinions on mixed-operators, and there is ongoing work
// to make the output code clear. It is better today then it was when the first
// PR to add prettier. That being said, the workaround for keeping this rule enabled
// requires breaking parts of operations into different variables -- which I believe
// to be worse. https://github.com/prettier/eslint-config-prettier#no-mixed-operators
'no-mixed-operators': 'off',
// Prettier wraps single line functions with ternaries, etc in parens by default, but
// if the line is long enough it breaks it into a separate line and removes the parens.
// The second behavior conflicts with this rule. There is some guides on the repo about
// how you can keep it enabled:
// https://github.com/prettier/eslint-config-prettier#no-confusing-arrow
// However, in practice this conflicts with prettier adding parens around short lines,
// when autofixing in vscode and others.
'no-confusing-arrow': 'off',
// There is no configuration in prettier for how it stylizes regexes, which conflicts
// with wrap-regex.
'wrap-regex': 'off',
// Prettier handles all indentation automagically. it can be configured here
// https://prettier.io/docs/en/options.html#tab-width but the default matches our
// style.
indent: 'off',
// This rule conflicts with the way that prettier breaks code across multiple lines when
// it exceeds the maximum length. Prettier optimizes for readability while simultaneously
// maximizing the amount of code per line.
'function-paren-newline': 'off',
// This rule throws an error when there is a line break in an arrow function declaration
// but prettier breaks arrow function declarations to be as readable as possible while
// still conforming to the width rules.
'implicit-arrow-linebreak': 'off',
// This rule would result in an increase in white space in lines with generator functions,
// which impacts prettier's goal of maximizing code per line and readability. There is no
// current workaround.
'generator-star-spacing': 'off',
'default-param-last': 'off',
'require-atomic-updates': 'off',
'import/no-unassigned-import': 'off',
'import/no-cycle': 'warn',
'prefer-object-spread': 'error',
'react/self-closing-comp': 'warn',
'react/no-unused-prop-types': 'warn',
'react/no-unused-state': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' },
],
'react/jsx-equals-spacing': 'error',
'react/no-deprecated': 'error',
'react/default-props-match-prop-types': 'error',
'react/jsx-closing-tag-location': [
'error',
{ selfClosing: 'tag-aligned', nonEmpty: 'tag-aligned' },
],
'react/jsx-no-duplicate-props': 'error',
'react/jsx-closing-bracket-location': 'error',
'react/jsx-first-prop-new-line': ['error', 'multiline'],
'react/jsx-max-props-per-line': [
'error',
{ maximum: 1, when: 'multiline' },
],
'react/jsx-tag-spacing': [
'error',
{
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
},
],
'no-invalid-this': 'off',
'@babel/no-invalid-this': 'error',
'import/no-unresolved': 'off',
'no-shadow': ['error', { builtinGlobals: false }],
// prettier handles these
semi: 'off',
'@babel/semi': 'off',
'mocha/no-setup-in-describe': 'off',
'node/no-process-env': 'off',
// TODO: re-enable these rules
'node/no-sync': 'off',
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
},
overrides: [
{
files: ['test/e2e/**/*.js'],
rules: {
'mocha/no-hooks-for-single-case': 'off',
},
},
{
files: ['app/scripts/migrations/*.js', '*.stories.js'],
rules: {
'import/no-anonymous-default-export': ['error', { allowObject: true }],
},
},
{
files: ['app/scripts/migrations/*.js'],
rules: {
'node/global-require': 'off',
},
},
{
files: ['test/**/*-test.js', 'test/**/*.spec.js'],
rules: {
// Mocha will re-assign `this` in a test context
'@babel/no-invalid-this': 'off',
},
},
{
files: ['development/**/*.js', 'test/e2e/benchmark.js', 'test/helper.js'],
rules: {
'node/no-process-exit': 'off',
'node/shebang': 'off',
},
},
{
files: [
'.eslintrc.js',
'babel.config.js',
'nyc.config.js',
'stylelint.config.js',
'app/scripts/lockdown-run.js',
'development/**/*.js',
'test/e2e/**/*.js',
'test/lib/wait-until-called.js',
'test/env.js',
'test/setup.js',
],
parserOptions: {
sourceType: 'script',
},
},
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx'],
},
},
react: {
version: 'detect',
},
},
};