-
Notifications
You must be signed in to change notification settings - Fork 5
/
typescript.js
126 lines (121 loc) · 3.95 KB
/
typescript.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
module.exports = {
extends: ['plugin:@typescript-eslint/eslint-recommended'],
overrides: [
{
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
files: ['*.ts', '*.tsx'],
rules: {
// swears on cases like constructor(public c: C) {}
'no-useless-constructor': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'class-methods-use-this': 'off',
'@typescript-eslint/member-ordering': [
'off',
{
default: [
'public-static-field',
'protected-static-field',
'private-static-field',
'public-static-method',
'protected-static-method',
'private-static-method',
'public-instance-field',
'protected-instance-field',
'private-instance-field',
'constructor',
'public-instance-method',
'protected-instance-method',
'private-instance-method',
],
},
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
String: { message: 'Use string instead', fixWith: 'string' },
Boolean: { message: 'Use boolean instead', fixWith: 'boolean' },
Number: { message: 'Use number instead', fixWith: 'number' },
Object: {
message: 'Use Record<string, any> instead',
fixWith: 'Record<string, any>',
},
object: {
message: 'Use Record<string, any> instead',
fixWith: 'Record<string, any>',
},
},
extendDefaults: false,
},
],
'@typescript-eslint/no-extraneous-class': [
'error',
{
allowWithDecorator: true,
allowStaticOnly: true,
},
],
// '@typescript-eslint/no-unnecessary-qualifier': 'error', need ts config
// '@typescript-eslint/restrict-plus-operands': 'error', need ts config
'@typescript-eslint/no-explicit-any': 'off',
camelcase: 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['PascalCase', 'UPPER_CASE'],
},
{
selector: 'property',
format: ['camelCase', 'PascalCase'],
},
],
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
// standard no-unused-expressions don't understand optional chaining from ts
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
},
],
'@typescript-eslint/no-var-requires': 'warn',
'@typescript-eslint/no-namespace': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: false,
variables: true,
enums: true,
typedefs: true,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
],
};