-
Notifications
You must be signed in to change notification settings - Fork 6
/
eslint.rules.js
157 lines (153 loc) · 5.46 KB
/
eslint.rules.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
const FIXME = {
// This is in the new 6.0.0 and we should switch this on
// at some point. For a first iteration we keep as-is
'@typescript-eslint/prefer-nullish-coalescing': 'off'
};
export const overrideAll = {
...FIXME,
// the next 2 enforce isolatedModules & verbatimModuleSyntax
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/no-non-null-assertion': 'error',
// ts itself checks and ignores those starting with _, align the linting
'@typescript-eslint/no-unused-vars': ['error', {
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
vars: 'all',
varsIgnorePattern: '^_'
}],
'@typescript-eslint/type-annotation-spacing': 'error',
'arrow-parens': ['error', 'always'],
'brace-style': ['error', '1tbs'],
curly: ['error', 'all'],
'default-param-last': 'off', // conflicts with TS version
'deprecation/deprecation': 'error',
'dot-notation': 'off', // conflicts with TS version
'func-style': ['error', 'declaration', {
allowArrowFunctions: true
}],
// this does help with declarations, but also
// applies to invocations, which is an issue...
// 'function-paren-newline': ['error', 'never'],
'function-call-argument-newline': ['error', 'consistent'],
'import-newlines/enforce': ['error', {
forceSingleLine: true,
items: 2048
}],
'import/export': 'error',
'import/extensions': ['error', 'ignorePackages', {
cjs: 'always',
js: 'always',
json: 'always',
jsx: 'never',
mjs: 'always',
ts: 'never',
tsx: 'never'
}],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'import/order': 'off', // conflicts with simple-import-sort
indent: 'off', // required as 'off' since typescript-eslint has own versions
'no-extra-semi': 'error',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'object-curly-newline': ['error', {
ExportDeclaration: { minProperties: 2048 },
ImportDeclaration: { minProperties: 2048 },
ObjectPattern: { minProperties: 2048 }
}],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
{ blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] },
{ blankLine: 'always', next: 'block-like', prev: '*' },
{ blankLine: 'always', next: '*', prev: 'block-like' },
{ blankLine: 'always', next: 'function', prev: '*' },
{ blankLine: 'always', next: '*', prev: 'function' },
{ blankLine: 'always', next: 'try', prev: '*' },
{ blankLine: 'always', next: '*', prev: 'try' },
{ blankLine: 'always', next: 'return', prev: '*' },
{ blankLine: 'always', next: 'import', prev: '*' },
{ blankLine: 'always', next: '*', prev: 'import' },
{ blankLine: 'any', next: 'import', prev: 'import' }
],
semi: ['error', 'always'],
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': ['error', {
groups: [
['^\u0000'], // all side-effects (0 at start)
['\u0000$', '^@polymeshassociation.*\u0000$', '^\\..*\u0000$'], // types (0 at end)
// ['^node:'], // node
['^[^/\\.]'], // non-polymesh
['^@polymeshassociation'], // polymesh
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'] // local (. last)
]
}],
'sort-destructure-keys/sort-destructure-keys': ['error', {
caseSensitive: true
}],
'sort-keys': 'error',
'spaced-comment': ['error', 'always', {
block: {
// pure export helpers
markers: ['#__PURE__']
},
line: {
// TS reference types
markers: ['/ <reference']
}
}]
};
export const overrideJsx = {
'jsx-quotes': ['error', 'prefer-single'],
// swap from recommended warning to error
'react-hooks/exhaustive-deps': 'error',
'react/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
'react/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
'react/jsx-fragments': 'error',
'react/jsx-max-props-per-line': ['warn', {
maximum: 1,
when: 'always'
}],
'react/jsx-newline': ['error', {
prevent: true
}],
'react/jsx-no-bind': 'error',
'react/jsx-props-no-multi-spaces': 'error',
'react/jsx-sort-props': ['warn', {
noSortAlphabetically: false
}],
'react/jsx-tag-spacing': ['error', {
afterOpening: 'never',
beforeClosing: 'never',
beforeSelfClosing: 'always',
closingSlash: 'never'
}],
'react/prop-types': 'off' // this is a completely broken rule
};
export const overrideJs = {
'@typescript-eslint/explicit-function-return-type': '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/no-var-requires': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off'
};
export const overrideSpec = {
// in the specs we are a little less worried about
// specific correctness, i.e. we can have dangling bits
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'jest/expect-expect': ['warn', {
assertFunctionNames: ['assert', 'expect']
}]
};