-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy path.eslintrc.js
More file actions
750 lines (739 loc) · 25.9 KB
/
.eslintrc.js
File metadata and controls
750 lines (739 loc) · 25.9 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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
const { readFileSync } = require('node:fs');
const path = require('node:path');
const ts = require('typescript');
const { version: reactVersion } = require('react/package.json');
const tsconfigPath = ts.findConfigFile('./', ts.sys.fileExists);
const { config } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
const tsconfig = ts.parseJsonConfigFileContent(config, ts.sys, './');
/**
* @type {import('eslint').Linter.Config }
*/
module.exports = {
root: true,
// Ignore files which are also in .prettierignore
ignorePatterns: readFileSync('.prettierignore', 'utf8').trim().split('\n'),
// eslint's parser, esprima, is not compatible with ESM, so use the babel parser instead
parser: '@babel/eslint-parser',
overrides: [
/**
* == Modules ==
*
* The first three sections here, which cover module syntax, are mutually
* exclusive: the set of files covered between them may NOT overlap. This is
* because we do not allow a file to use two different styles for specifying
* imports and exports (however theoretically possible it may be).
*/
{
/**
* Modules (CommonJS module syntax)
*
* This is code that uses `require()` and `module.exports` to import and
* export other modules.
*/
files: [
'.eslintrc.js',
'.eslintrc.*.js',
'.mocharc.js',
'*.config.js',
'app/scripts/lockdown-run.js',
'app/scripts/lockdown-more.js',
'development/**/*.js',
'test/e2e/**/*.js',
'test/helpers/*.js',
'test/run-unit-tests.js',
],
extends: [
path.resolve(__dirname, '.eslintrc.base.js'),
path.resolve(__dirname, '.eslintrc.node.js'),
path.resolve(__dirname, '.eslintrc.babel.js'),
path.resolve(__dirname, '.eslintrc.typescript-compat.js'),
],
settings: {
'import-x/resolver': {
// When determining the location of a `require()` call, use Node's
// resolution algorithm, then fall back to TypeScript's. This allows
// TypeScript files (which Node's algorithm doesn't recognize) to be
// imported from JavaScript files, while also preventing issues when
// using packages like `prop-types` (where we would otherwise get "No
// default export found in imported module 'prop-types'" from
// TypeScript because imports work differently there).
node: {},
typescript: {
// Always try to resolve types under `<root>/@types` directory even
// it doesn't contain any source code, like `@types/unist`
alwaysTryTypes: true,
},
},
},
},
/**
* Modules (ES module syntax)
*
* This is code that explicitly uses `import`/`export` instead of
* `require`/`module.exports`.
*/
{
files: [
'app/**/*.js',
'shared/**/*.js',
'ui/**/*.js',
'**/*.test.js',
'test/lib/**/*.js',
'test/mocks/**/*.js',
'test/jest/**/*.js',
'test/stub/**/*.js',
'test/unit-global/**/*.js',
],
excludedFiles: [
'app/scripts/lockdown-run.js',
'app/scripts/lockdown-more.js',
],
extends: [
path.resolve(__dirname, '.eslintrc.base.js'),
path.resolve(__dirname, '.eslintrc.node.js'),
path.resolve(__dirname, '.eslintrc.babel.js'),
path.resolve(__dirname, '.eslintrc.typescript-compat.js'),
],
parserOptions: {
sourceType: 'module',
},
settings: {
'import-x/resolver': {
// When determining the location of an `import`, use Node's resolution
// algorithm, then fall back to TypeScript's. This allows TypeScript
// files (which Node's algorithm doesn't recognize) to be imported
// from JavaScript files, while also preventing issues when using
// packages like `prop-types` (where we would otherwise get "No
// default export found in imported module 'prop-types'" from
// TypeScript because imports work differently there).
node: {},
typescript: {
// Always try to resolve types under `<root>/@types` directory even
// it doesn't contain any source code, like `@types/unist`
alwaysTryTypes: true,
},
},
},
},
/**
* TypeScript files
*/
{
files: tsconfig.fileNames.filter((f) => /\.tsx?$/u.test(f)),
parserOptions: {
project: tsconfigPath,
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
tsconfigRootDir: __dirname,
},
extends: [
path.resolve(__dirname, '.eslintrc.base.js'),
'@metamask/eslint-config-typescript',
path.resolve(__dirname, '.eslintrc.typescript-compat.js'),
],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
// this rule is new, but we didn't use it before, so it's off now
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-shadow': [
'error',
{
builtinGlobals: true,
allow: [
'ErrorOptions',
'Text',
'Screen',
'KeyboardEvent',
'Lock',
'Notification',
'CSS',
'Props',
],
},
],
// `no-parameter-properties` was removed in favor of `parameter-properties`
// Yeah, they have opposite names but do the same thing?!
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/parameter-properties': 'error',
// Turn these off, as it's recommended by typescript-eslint.
// See: <https://typescript-eslint.io/docs/linting/troubleshooting#eslint-plugin-import>
'import-x/named': 'off',
'import-x/namespace': 'off',
'import-x/default': 'off',
'import-x/no-named-as-default-member': 'off',
// Set to ban interfaces due to their incompatibility with Record<string, unknown>.
// See: <https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440>
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
// This rule temporarily applies the latest `@typescript-eslint/naming-convention` config found in `@metamask/eslint-config`.
// TODO: Remove once `@metamask/eslint-config` is updated to `^14.0.0`.
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'forbid',
},
{ selector: 'enumMember', format: ['PascalCase'] },
{
selector: 'function',
modifiers: ['exported'],
format: ['camelCase', 'PascalCase'],
},
{
selector: 'import',
format: ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE'],
},
{
selector: 'interface',
format: ['PascalCase'],
custom: { regex: '^I[A-Z]', match: false },
},
{
selector: 'objectLiteralMethod',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'objectLiteralProperty',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{ selector: 'typeLike', format: ['PascalCase'] },
{
selector: 'typeParameter',
format: ['PascalCase'],
custom: { regex: '^.{3,}', match: true },
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'parameter',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
format: null,
modifiers: ['requiresQuotes'],
},
],
// This rule temporarily applies the latest `@typescript-eslint/restrict-template-expressions` config found in `@metamask/eslint-config`.
// TODO: Remove once `@metamask/eslint-config` is updated to `^14.0.0`.
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowBoolean: true,
allowNumber: true,
},
],
// TODO: Remove once `@metamask/eslint-config-typescript` is updated to a version with this setting.
'consistent-return': '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
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-readonly': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'off',
'@typescript-eslint/unbound-method': 'off',
'import-x/no-named-as-default': 'off',
'no-restricted-syntax': [
'error',
{
selector: 'WithStatement',
message: 'With statements are not allowed',
},
{
selector: 'SequenceExpression',
message: 'Sequence expressions are not allowed',
},
// {
// selector: "BinaryExpression[operator='in']",
// message: 'The "in" operator is not allowed',
// },
// {
// selector:
// "PropertyDefinition[accessibility='private'], MethodDefinition[accessibility='private'], TSParameterProperty[accessibility='private']",
// message: 'Use a hash name instead.',
// },
],
},
settings: {
'import-x/resolver': {
// When determining the location of an `import`, prefer TypeScript's
// resolution algorithm. Note that due to how we've configured
// TypeScript in `tsconfig.json`, we are able to import JavaScript
// files from TypeScript files.
typescript: {
// Always try to resolve types under `<root>/@types` directory even
// it doesn't contain any source code, like `@types/unist`
alwaysTryTypes: true,
},
},
},
},
{
files: ['.agents/**/*.ts'],
rules: {
'import-x/no-nodejs-modules': 'off',
},
},
/**
* == Everything else ==
*
* The sections from here on out may overlap with each other in various
* ways depending on their function.
*/
/**
* React-specific code
*
* Code in this category contains JSX and hence needs to be run through the
* React plugin.
*/
{
files: [
'test/lib/render-helpers.js',
'test/jest/rendering.js',
'ui/**/*.js',
],
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react', 'react-compiler'],
rules: {
'react-compiler/react-compiler': 'error',
'react/no-unused-prop-types': 'error',
'react/no-unused-state': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': [
'error',
{
props: 'never',
children: 'never',
},
],
'react/no-deprecated': 'error',
'react/default-props-match-prop-types': 'error',
'react/jsx-no-duplicate-props': 'error',
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: 'useAsync(Callback|Result|ResultOrThrow)',
},
],
},
settings: {
react: {
// If this is set to 'detect', ESLint will import React in order to
// find its version. Because we run ESLint in the build system under
// LavaMoat, this means that detecting the React version requires a
// LavaMoat policy for all of React, in the build system. That's a
// no-go, so we grab it from React's package.json.
version: reactVersion,
},
},
},
/**
* TypeScript React-specific code
*
* Similar to above, but marks a majority of errors to warnings.
* TODO - combine rulesets and resolve errors
*/
{
files: ['ui/**/*.ts', 'ui/**/*.tsx'],
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react', 'react-compiler'],
rules: {
'react-compiler/react-compiler': 'error',
'react/no-unused-prop-types': 'error',
'react/no-unused-state': 'warn',
'react/jsx-boolean-value': 'off',
'react/jsx-curly-brace-presence': 'off',
'react/no-deprecated': 'warn',
'react/default-props-match-prop-types': 'warn',
'react/jsx-no-duplicate-props': 'warn',
'react/display-name': 'off',
'react/no-unescaped-entities': 'error',
'react/prop-types': 'off',
'react/no-children-prop': 'off',
'react/jsx-key': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: 'useAsync(Callback|Result|ResultOrThrow)',
},
],
},
settings: {
react: {
// If this is set to 'detect', ESLint will import React in order to
// find its version. Because we run ESLint in the build system under
// LavaMoat, this means that detecting the React version requires a
// LavaMoat policy for all of React, in the build system. That's a
// no-go, so we grab it from React's package.json.
version: reactVersion,
},
},
},
/**
* Tailwind CSS
*/
{
files: [
'ui/pages/design-system/**/*.{ts,tsx}',
// Add your workspace if you'd like to start using tailwind css,
// for example:
// 'ui/pages/your-page/**/*.{ts,tsx}',
],
plugins: ['tailwindcss'],
rules: {
// Tailwind CSS rules - same as design system
'tailwindcss/classnames-order': 'error',
'tailwindcss/enforces-negative-arbitrary-values': 'error',
'tailwindcss/enforces-shorthand': 'error',
'tailwindcss/no-arbitrary-value': 'off', // There are legitimate reasons to use arbitrary values but we should specifically error on static colors
'tailwindcss/no-custom-classname': 'error',
'tailwindcss/no-contradicting-classname': 'error',
'tailwindcss/no-unnecessary-arbitrary-value': 'error',
},
settings: {
tailwindcss: {
callees: ['twMerge'],
config: 'tailwind.config.js',
classRegex: ['^(class(Name)?)$'],
},
},
},
/**
* Mocha tests
*
* These are files that make use of globals and syntax introduced by the
* Mocha library.
*/
{
files: ['test/e2e/**/*.spec.{js,ts}'],
extends: ['@metamask/eslint-config-mocha'],
rules: {
// In Mocha tests, it is common to use `this` to store values or do
// things like force the test to fail.
'@babel/no-invalid-this': 'off',
'mocha/no-setup-in-describe': 'off',
// Static hex values are only discouraged in application code, using them in tests is OK.
'@metamask/design-tokens/color-no-hex': '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
'mocha/consistent-spacing-between-blocks': 'off',
},
},
/**
* Jest tests
*
* These are files that make use of globals and syntax introduced by the
* Jest library.
* TODO: This list of files is incomplete, and should be replaced with globs that match the
* Jest config.
*/
{
files: [
'**/__snapshots__/*.snap',
'app/scripts/controllers/app-state-controller.test.ts',
'app/scripts/controllers/alert-controller.test.ts',
'app/scripts/metamask-controller.actions.test.js',
'app/scripts/detect-multiple-instances.test.js',
'app/scripts/controllers/swaps/**/*.test.js',
'app/scripts/controllers/swaps/**/*.test.ts',
'app/scripts/controllers/metametrics.test.js',
'app/scripts/controllers/permissions/**/*.test.js',
'app/scripts/controllers/preferences-controller.test.ts',
'app/scripts/controllers/account-tracker-controller.test.ts',
'app/scripts/lib/**/*.test.js',
'app/scripts/metamask-controller.test.js',
'app/scripts/migrations/*.test.js',
'app/scripts/platforms/*.test.js',
'development/**/*.test.js',
'development/**/*.test.ts',
'shared/**/*.test.js',
'shared/**/*.test.ts',
'test/helpers/*.js',
'test/jest/*.js',
'test/lib/timer-helpers.js',
'test/e2e/helpers.test.js',
'test/unit-global/*.test.js',
'ui/**/*.test.js',
'ui/__mocks__/*.js',
'shared/lib/error-utils.test.ts',
],
extends: ['@metamask/eslint-config-jest'],
parserOptions: {
sourceType: 'module',
},
rules: {
'import-x/unambiguous': 'off',
'import-x/named': 'off',
// Static hex values are only discouraged in application code, using them in tests is OK.
'@metamask/design-tokens/color-no-hex': 'off',
// *.snap files weren't parsed by previous versions of this eslint
// config section, but something got fixed somewhere, and now this rule
// causes failures. We need to turn it off instead of fix them because
// we aren't even remotely close to being in alignment. If it bothers
// you open a PR to fix it yourself.
'jest/no-large-snapshots': 'off',
'jest/no-restricted-matchers': 'off',
/**
* jest/prefer-to-be is a new rule that was disabled to reduce churn
* when upgrading eslint. It should be considered for use and enabled
* in a future PR if agreeable.
*/
'jest/prefer-to-be': 'off',
/**
* jest/lowercase-name was renamed to jest/prefer-lowercase-title this
* change was made to essentially retain the same state as the original
* eslint-config-jest until it is updated. At which point the following
* two lines can be deleted.
*/
'jest/lowercase-name': 'off',
'jest/prefer-lowercase-title': [
'error',
{
ignore: ['describe'],
},
],
},
},
/**
* Jest files that aren't currently covered by Jest configuration above
*
* TODO: Update the `files` list for the Jest configuration.
*/
{
files: ['**/*.test.{js,ts,tsx}'],
rules: {
// Static hex values are only discouraged in application code, using them in tests is OK.
'@metamask/design-tokens/color-no-hex': 'off',
},
},
/**
* Legacy migrations
*/
{
files: ['app/scripts/migrations/*.js'],
rules: {
// Disable various rules that our legacy migrations don't follow
'import-x/no-anonymous-default-export': 'off',
},
},
/**
* Executables and related files
*
* These are files that run in a Node context. They are either designed to
* run as executables (in which case they will have a shebang at the top) or
* are dependencies of executables (in which case they may use
* `process.exit` to exit).
*/
{
files: ['development/**/*.js', 'test/helpers/setup-helper.js'],
rules: {
'n/no-process-exit': 'off',
'n/hashbang': 'off',
},
},
/**
* Lockdown files
*/
{
files: [
'app/scripts/lockdown-run.js',
'app/scripts/lockdown-more.js',
'test/helpers/protect-intrinsics-helpers.js',
'test/unit-global/protect-intrinsics.test.js',
],
globals: {
harden: 'readonly',
Compartment: 'readonly',
},
},
/**
* Storybook
*/
{
files: ['**/*.stories.js', '**/*.stories.ts', '**/*.stories.tsx'],
// Suggested addition from the storybook 6.5 update
extends: ['plugin:storybook/recommended'],
rules: {
// Anonymous object exports are conventional for Storybook files
'import-x/no-anonymous-default-export': [
'error',
{
allowObject: true,
},
],
// Static hex values are only discouraged in application code, using them in stories is OK.
'@metamask/design-tokens/color-no-hex': 'off',
'storybook/no-redundant-story-name': 'error',
},
},
/**
* Modules with sorted keys (to be expanded over time)
*
* TODO: Either continue migrating code to this rule, or abandon the effort.
*/
{
files: ['ui/pages/settings/*.js'],
rules: {
'sort-keys': [
'error',
'asc',
{
natural: true,
},
],
},
},
/**
* Modules with sorted imports
*
* TODO: Remove in favor of `import-x/order`, which our shared config uses.
*/
{
files: ['ui/components/multichain/**/*.{js}'],
rules: {
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: true,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],
},
},
/**
* Proof files for type-level testing (compile-time assertions, no runtime code)
*/
{
files: ['**/*.proof.ts'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
varsIgnorePattern: '^Describe_',
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeLike',
format: ['PascalCase'],
leadingUnderscore: 'allow',
filter: { regex: '^Describe_', match: false },
},
{
selector: 'typeLike',
format: null,
filter: { regex: '^Describe_', match: true },
},
{
selector: 'typeProperty',
format: ['camelCase', 'PascalCase'],
},
],
},
},
/**
* TypeScript declaration files.
*
* TODO: Move this to `@metamask/eslint-config-typescript`
*/
{
files: ['**/*.d.ts'],
rules: {
'import-x/unambiguous': 'off',
},
},
/**
* Prevent new references to deprecated "globally selected network"
*
* This can be removed after all usages have been removed.
*
* TODO: Expand coverage to include non-confirmation UI as well.
*/
{
files: ['ui/pages/confirmations/**/*.{js,ts,tsx}'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: `ImportSpecifier[imported.name=/${[
'getConversionRate',
'getCurrentChainId',
'getNativeCurrency',
'getNetworkIdentifier',
'getNftContracts',
'getNfts',
'getProviderConfig',
'getRpcPrefsForCurrentProvider',
'getUSDConversionRate',
'isCurrentProviderCustom',
]
.map((method) => `(${method})`)
.join('|')}/]`,
message: 'Avoid using global network selectors in confirmations',
},
],
},
},
],
};