generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheslint.config.mjs
155 lines (150 loc) · 4.28 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
import base, { createConfig } from '@metamask/eslint-config';
import nodejs from '@metamask/eslint-config-nodejs';
import jest from '@metamask/eslint-config-jest';
import typescript from '@metamask/eslint-config-typescript';
const config = createConfig(
{
ignores: [
'yarn.lock',
'**/**.map',
'**/**.tsbuildinfo',
'**/*.json',
'**/*.md',
'**/LICENSE',
'**/*.sh',
'**/.DS_Store',
'**/dist/**',
'**/docs/**',
'**/coverage/**',
'merged-packages/**',
'.yarn/**',
'scripts/create-package/package-template/**',
'apps/storybook-react-native/.storybook/FontLoader.js',
'apps/storybook-react-native/.storybook/config.js',
'packages/design-system-react-native/jest.setup.js',
],
},
...base,
{
rules: {
// Left disabled because various properties throughout this repo are snake_case because the
// names come from external sources or must comply with standards
// e.g. `txreceipt_status`, `signTypedData_v4`, `token_id`
// camelcase: 'off',
'id-length': 'off',
// TODO: re-enble most of these rules
'@typescript-eslint/naming-convention': 'off',
'function-paren-newline': 'off',
'id-denylist': 'off',
'implicit-arrow-linebreak': 'off',
'import/no-anonymous-default-export': 'off',
'import/no-unassigned-import': 'off',
'lines-around-comment': 'off',
'n/no-sync': 'off',
'no-async-promise-executor': 'off',
'no-case-declarations': 'off',
'no-invalid-this': 'off',
'no-negated-condition': 'off',
'no-new': 'off',
'no-param-reassign': 'off',
'no-restricted-syntax': 'off',
radix: 'off',
'require-atomic-updates': 'off',
'jsdoc/match-description': [
'off',
{ matchDescription: '^[A-Z`\\d_][\\s\\S]*[.?!`>)}]$' },
],
},
settings: {
jsdoc: {
mode: 'typescript',
},
},
},
{
files: [
'**/jest.config.js',
'**/jest.environment.js',
'**/tests/**/*.{ts,js,tsx}',
'*.js',
'*.test.{ts,js,tsx}',
'scripts/*.ts',
'scripts/create-package/*.ts',
'yarn.config.cjs',
],
extends: [nodejs],
},
{
files: ['*.test.{ts,js,tsx}', '**/tests/**/*.{ts,js,tsx}'],
extends: [jest],
},
{
// These files are test helpers, not tests. We still use the Jest ESLint
// config here to ensure that ESLint expects a test-like environment, but
// various rules meant just to apply to tests have been disabled.
files: ['**/tests/**/*.{ts,js,tsx}', '!*.test.{ts,js,tsx}'],
rules: {
'jest/no-export': 'off',
'jest/require-top-level-describe': 'off',
'jest/no-if': 'off',
},
},
{
files: ['*.js', '*.cjs'],
parserOptions: {
sourceType: 'script',
ecmaVersion: '2020',
},
},
{
files: ['*.ts', '*.tsx'],
extends: [typescript],
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: ['./tsconfig.packages.json'],
},
rules: {
// Enable rules that are disabled in `@metamask/eslint-config-typescript`
'@typescript-eslint/no-explicit-any': 'error',
// TODO: auto-fix breaks stuff
'@typescript-eslint/promise-function-async': 'off',
// TODO: re-enable most of these rules
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
'no-restricted-syntax': 'off',
'no-restricted-globals': 'off',
},
},
{
files: ['tests/setupAfterEnv/matchers.ts'],
parserOptions: {
sourceType: 'script',
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/naming-convention': 'warn',
'import/unambiguous': 'off',
},
},
{
files: ['scripts/*.ts'],
rules: {
// All scripts will have shebangs.
'n/shebang': 'off',
},
},
{
files: ['**/jest.environment.js'],
rules: {
// These files run under Node, and thus `require(...)` is expected.
'n/global-require': 'off',
},
},
);
export default config;