-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path.eslintrc.js
158 lines (158 loc) · 4.56 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
module.exports = {
root: true,
extends: [
'react-app',
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
'plugin:jest-formatting/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
plugins: ['sort-imports-es6-autofix', 'eslint-plugin-tsdoc', 'prettier'],
rules: {
curly: 'error',
'import/no-anonymous-default-export': [
'error',
{
allowNew: true,
},
],
'no-restricted-imports': 'off',
'@typescript-eslint/no-restricted-imports': [
'error',
{
patterns: [
{
group: ['url-parse'],
importNames: ['qs', 'extractProtocol', 'location', 'trimLeft'],
message:
"Named exports from url-parse do not work under node's ESM/CJS interop. You will need to import the default export and access the property you want from there, like this: `import urlparse from 'url-parse'; urlparse.qs.parse(...)`",
},
{
group: ['uuid'],
importNames: ['v1', 'v4'],
message:
"Named exports from uuid do not work under node's ESM/CJS interop. You will need to import the default export and use that export as a function, like this: `import uuid from 'uuid'; uuid(...)`",
},
{
group: ['lodash'],
message:
"Do not use lodash as this package is ESM only. Use lodash-es instead like this: `import { xxx } from 'lodash-es';`",
},
],
},
],
'require-await': 'error',
'no-duplicate-imports': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'local', args: 'after-used', ignoreRestSiblings: true },
],
'sort-imports-es6-autofix/sort-imports-es6': [
'error',
{
ignoreCase: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
},
],
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false },
],
'@typescript-eslint/padding-line-between-statements': [
'error',
{
blankLine: 'never',
prev: 'singleline-const',
next: 'singleline-const',
},
{
blankLine: 'never',
prev: 'singleline-let',
next: 'singleline-let',
},
{ blankLine: 'never', prev: 'import', next: 'import' },
{ blankLine: 'always', prev: '*', next: 'return' },
{
blankLine: 'always',
prev: '*',
next: ['class', 'if', 'while', 'switch', 'try'],
},
{
blankLine: 'always',
prev: ['class', 'if', 'while', 'switch', 'try'],
next: '*',
},
{ blankLine: 'always', prev: '*', next: ['const', 'let', 'var'] },
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{
blankLine: 'any',
prev: ['const', 'let', 'var'],
next: ['const', 'let', 'var'],
},
{ blankLine: 'always', prev: 'import', next: '*' },
{ blankLine: 'any', prev: 'import', next: 'import' },
{
blankLine: 'always',
prev: '*',
next: ['interface', 'type'],
},
],
'spaced-comment': ['error', 'always'],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/ban-ts-comment': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'tsdoc/syntax': 'warn',
},
overrides: [
// Disable all tsdoc checking in test files
{
files: ['*.test.*[t|j]s*', '*.fixtures.*[t|j]s*'],
rules: {
'tsdoc/syntax': 'off',
// We use const xxx = () => {} many times in tests.
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'jest/expect-expect': [
'error',
{
assertFunctionNames: ['expect', 'assert*'],
},
],
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['gitpkg.config.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
],
};