-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
191 lines (185 loc) · 6.61 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
// Copyright 2019-2021 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
// const base = require("@dust-defi/dev/config/eslint.cjs");
// module.exports = {
// root: true,
// // ...base,
// ignorePatterns: [
// ".eslintrc.js",
// ".github/**",
// ".vscode/**",
// ".yarn/**",
// "**/build/*",
// "**/coverage/*",
// "**/node_modules/*",
// ],
// parserOptions: {
// // ...base.parserOptions,
// project: ["./tsconfig.json"],
// "sourceType": "module"
// },
// rules: {
// // ...base.rules,
// // this seems very broken atm, false positives
// // "@typescript-eslint/unbound-method": "off",
// // "@typescript-eslint/no-unsafe-assignment":"off",
// // "@typescript-eslint/no-unsafe-member-access":"off",
// // "@typescript-eslint/no-explicit-any":"off",
// // "@typescript-eslint/ban-ts-comment":"off",
// // "@typescript-eslint/no-misused-promises":"off",
// // "@typescript-eslint/no-floating-promises":"off",
// // "@typescript-eslint/no-empty-function":"off",
// // "@typescript-eslint/no-unsafe-call":"off",
// // "@typescript-eslint/no-unsafe-return":"off",
// // "@typescript-eslint/restrict-template-expressions":"off",
// },
// };
// This code was copied from from @dust-defi/dev/config/eslint.cjs
// In addition ignorePatterns was added and parser options links to projects tsconfig.json
// Added all previously named rules
// * This is not the most optimal solution!
// * Default esling config must be extracted from named package
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
env: {
browser: true,
jest: true,
node: true
},
extends: [
'eslint:recommended',
require.resolve('eslint-config-standard'),
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended'
],
overrides: [{
files: ['*.js', '*.cjs', '*.mjs'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off'
}
}],
parser: require.resolve('@typescript-eslint/parser'),
ignorePatterns: [
".eslintrc.js",
".github/**",
".vscode/**",
".yarn/**",
"**/build/*",
"**/coverage/*",
"**/node_modules/*",
],
parserOptions: {
extraFileExtensions: ['.cjs', '.mjs'],
warnOnUnsupportedTypeScriptVersion: false,
project: ["./tsconfig.json"],
"sourceType": "module"
},
plugins: [
'@typescript-eslint',
'header',
'import',
'import-newlines',
'react-hooks',
'simple-import-sort',
'sort-destructure-keys'
],
rules: {
// required as 'off' since typescript-eslint has own versions
indent: 'off',
'no-use-before-define': 'off',
'@typescript-eslint/indent': ['error', 2],
// rules from semistandard (don't include it, has standard dep version mismatch)
semi: [2, 'always'],
'no-extra-semi': 2,
// specific overrides
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'arrow-parens': ['error', 'always'],
'default-param-last': [0], // conflicts with TS version (this one doesn't allow TS ?)
'import-newlines/enforce': ['error', 2048],
'jsx-quotes': ['error', 'prefer-single'],
'react/prop-types': [0], // this is a completely broken rule
'object-curly-newline': ['error', {
ImportDeclaration: 'never',
ObjectPattern: 'never'
}],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
{ blankLine: 'always', prev: '*', next: 'block-like' },
{ blankLine: 'always', prev: 'block-like', next: '*' },
{ blankLine: 'always', prev: '*', next: 'function' },
{ blankLine: 'always', prev: 'function', next: '*' },
{ blankLine: 'always', prev: '*', next: 'try' },
{ blankLine: 'always', prev: 'try', next: '*' },
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: '*', next: 'import' },
{ blankLine: 'always', prev: 'import', next: '*' },
{ blankLine: 'any', prev: 'import', next: 'import' }
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'react/jsx-closing-bracket-location': [1, 'tag-aligned'],
'react/jsx-first-prop-new-line': [1, 'multiline-multiprop'],
'react/jsx-fragments': 'error',
'react/jsx-max-props-per-line': [1, {
maximum: 1,
when: 'always'
}],
'react/jsx-no-bind': 2,
'react/jsx-sort-props': [1, {
noSortAlphabetically: false
}],
'react/jsx-tag-spacing': [2, {
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
beforeClosing: 'never'
}],
'sort-destructure-keys/sort-destructure-keys': [2, {
caseSensitive: true
}],
'simple-import-sort/imports': [2, {
groups: [
['^\u0000'], // all side-effects (0 at start)
['\u0000$', '^@polkadot.*\u0000$', '^\\..*\u0000$'], // types (0 at end)
['^[^/\\.]'], // non-polkadot
['^@polkadot'], // polkadot
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'] // local (. last)
]
}],
'sort-keys': 'error',
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unsafe-assignment":"off",
"@typescript-eslint/no-unsafe-member-access":"off",
"@typescript-eslint/no-explicit-any":"off",
"@typescript-eslint/ban-ts-comment":"off",
"@typescript-eslint/no-misused-promises":"off",
"@typescript-eslint/no-floating-promises":"off",
"@typescript-eslint/no-empty-function":"off",
"@typescript-eslint/no-unsafe-call":"off",
"@typescript-eslint/no-unsafe-return":"off",
"@typescript-eslint/restrict-template-expressions":"off",
"react/jsx-no-bind": "warn"
},
settings: {
'import/extensions': ['.js', '.ts', '.tsx'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': require.resolve('eslint-import-resolver-node'),
react: {
version: 'detect'
}
}
};