-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy path.eslintrc.base.js
More file actions
176 lines (160 loc) · 5.37 KB
/
.eslintrc.base.js
File metadata and controls
176 lines (160 loc) · 5.37 KB
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
module.exports = {
extends: ['@metamask/eslint-config'],
plugins: ['@metamask/design-tokens'],
globals: {
document: 'readonly',
window: 'readonly',
// Our ESLint config is stuck at ES2017 because Browserify doesn't support the spread operator.
// We can remove this global after we've migrated away from Browserify and updated our ESLint
// config to at least ES2021.
AggregateError: 'readonly',
},
settings: {
jsdoc: {
mode: 'typescript',
},
},
rules: {
'default-param-last': 'off',
'prefer-object-spread': 'error',
'require-atomic-updates': 'off',
// This is the same as our default config, but for the noted exceptions
'spaced-comment': [
'error',
'always',
{
markers: [
'global',
'globals',
'eslint',
'eslint-disable',
'*package',
'!',
',',
// Local additions
'/:', // This is for our code fences
],
exceptions: ['=', '-'],
},
],
'no-invalid-this': 'off',
// TODO: remove this override
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: 'directive',
next: '*',
},
{
blankLine: 'any',
prev: 'directive',
next: 'directive',
},
// Disabled temporarily to reduce conflicts while PR queue is large
// {
// blankLine: 'always',
// prev: ['multiline-block-like', 'multiline-expression'],
// next: ['multiline-block-like', 'multiline-expression'],
// },
],
// It is common to import modules without assigning them to variables in
// a browser context. For instance, we may import polyfills which change
// global variables, or we may import stylesheets.
'import-x/no-unassigned-import': 'off',
// import-x/no-named-as-default-member checks if default imports also have
// named exports matching properties used on the default import. Example:
// in confirm-seed-phrase-component.test.js we import sinon from 'sinon'
// and later access sinon.spy. spy is also exported from sinon directly and
// thus triggers the error. Turning this rule off to prevent churn when
// upgrading eslint and dependencies. This rule should be evaluated and
// if agreeable turned on upstream in @metamask/eslint-config
'import-x/no-named-as-default-member': 'off',
// This is necessary to run eslint on Windows and not get a thousand CRLF errors
'prettier/prettier': ['error', { endOfLine: 'auto' }],
'@metamask/design-tokens/color-no-hex': 'error',
'import-x/no-restricted-paths': [
'error',
{
basePath: './',
zones: [
{
target: './app',
from: './ui',
message:
'Should not import from UI in background, use shared directory instead',
},
{
target: './ui',
from: './app',
message:
'Should not import from background in UI, use shared directory instead',
},
{
target: './shared',
from: './app',
message: 'Should not import from background in shared',
},
{
target: './shared',
from: './ui',
message: 'Should not import from UI in shared',
},
],
},
],
/* JSDoc plugin rules */
// TODO: re-enable once the proposed feature at https://github.com/gajus/eslint-plugin-jsdoc/pull/964#issuecomment-1936470252 is available
'jsdoc/check-line-alignment': 'off',
// Allow tag `jest-environment` to work around Jest bug
// See: https://github.com/facebook/jest/issues/7780
'jsdoc/check-tag-names': ['error', { definedTags: ['jest-environment'] }],
// TODO: Re-enable these
'jsdoc/match-description': 'off',
'jsdoc/require-description': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/valid-types': 'off',
// These rule modifications are removing changes to our shared ESLint config made after
// version v9. This is a temporary measure to get us to ESLint v9 compatible versions,
// at which point we can restore the intended rules and use error suppression instead.
//
// TODO: Remove these modifications after the ESLint v9 update
'no-loss-of-precision': 'off',
'no-restricted-globals': ['error', 'event'],
'id-denylist': 'off',
'id-length': 'off',
'import-x/order': [
'error',
{
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
'newlines-between': 'ignore',
alphabetize: {
order: 'ignore',
caseInsensitive: false,
},
},
],
'import-x/no-nodejs-modules': 'off',
'jsdoc/tag-lines': 'off',
'no-restricted-syntax': [
'error',
{
selector: 'WithStatement',
message: 'With statements are not allowed',
},
// {
// selector: "BinaryExpression[operator='in']",
// message: 'The "in" operator is not allowed',
// },
{
selector: 'SequenceExpression',
message: 'Sequence expressions are not allowed',
},
],
},
};