forked from kentcdodds/eslint-config-kentcdodds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstylistic.js
168 lines (163 loc) · 6.38 KB
/
stylistic.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
module.exports = {
extends: ['./non-rules-config.js', 'prettier'],
rules: {
camelcase: 'off', // annoying to disable...
'capitalized-comments': 'off', // wHO CaRes?
'consistent-this': 'off', // Too many use-cases for reassigning "this" to different values
curly: ['error', 'multi-line'],
'func-name-matching': 'error',
'func-names': 'error',
'func-style': 'off',
'id-denylist': 'error',
'id-length': 'off', // when using short composable functions, using single-letter variables is fine
'id-match': [
'error',
// camelCase, PascalCase, __filename, CONST_VALUE, stream$, $el
'^\\$?(__)?(([A-Z]|[a-z]|[0-9]+)|([A-Z_]))*\\$?$',
],
'line-comment-position': 'off',
'lines-between-class-members': [
'error',
'always',
{exceptAfterSingleLine: false},
],
'max-depth': ['error', 4],
'max-lines': [
'error',
{max: 2500, skipBlankLines: false, skipComments: false},
],
'max-lines-per-function': 'off', // this becomes an obvious problem when it's actually a problem...
'max-nested-callbacks': ['error', 7],
'max-params': ['error', 7],
'max-statements': 'off', // this becomes an obvious problem when it's actually a problem...
'max-statements-per-line': ['error', {max: 1}],
'multiline-comment-style': 'off', // this would be cool to get the fixer, but too strict.
'new-cap': 'error',
'no-array-constructor': 'error',
'no-bitwise': 'error',
'no-continue': 'off',
'no-inline-comments': 'off',
'no-lonely-if': 'error',
'no-multi-assign': 'error', // it's handy, but harder to read
'no-negated-condition': 'error',
'no-nested-ternary': 'off',
'no-new-object': 'error',
'no-plusplus': 'off',
'no-restricted-syntax': ['error', 'WithStatement'],
'no-ternary': 'off',
'no-underscore-dangle': 'off',
'no-unneeded-ternary': 'error',
'one-var': ['error', {uninitialized: 'always', initialized: 'never'}],
'operator-assignment': 'off', // readability on a case-by-case basis
'padding-line-between-statements': 'off', // meh...
'prefer-exponentiation-operator': 'warn',
'prefer-object-spread': 'warn',
'sort-keys': 'off',
'sort-vars': 'off',
'spaced-comment': 'off',
// variables
'init-declarations': 'off',
},
overrides: [
{
files: ['**/*.ts?(x)'],
rules: {
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': 'off',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'init-declarations': 'off',
'@typescript-eslint/init-declarations': 'off',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/ban-tslint-comment': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': 'off', // I think I prefer typed imports, but you can't always use them
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/method-signature-style': 'off',
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
'@typescript-eslint/naming-convention': [
'error',
// Enforce that all variables are either in camelCase, PascalCase or UPPER_CASE,
// Allow PascalCase in const, sometimes represent react components
{
selector: 'default',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allowSingleOrDouble',
trailingUnderscore: 'allowSingleOrDouble',
},
// Enforce that boolean variables are prefixed with an allowed verb
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
},
// Ignore destructured names:
// Sometimes you might want to allow destructured properties to retain
// their original name, even if it breaks your naming convention.
{
selector: 'variable',
modifiers: ['destructured'],
format: null,
},
{
selector: 'variable',
types: ['boolean'],
modifiers: ['destructured'],
format: null,
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'forbid',
},
{
selector: ['typeLike', 'enumMember'],
format: ['PascalCase'],
},
{
selector: ['typeParameter'],
format: ['PascalCase'],
custom: {
regex: '[a-zA-Z0-9]{2,}',
match: true,
},
},
// Ignore properties that require quotes
{
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
format: null,
modifiers: ['requiresQuotes'],
},
],
'@typescript-eslint/no-confusing-non-null-assertion': 'off', // prettier reformats their "correct" example anyway 🤷♂️
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-parameter-properties': 'error', // yeah, I don't like this feature
'@typescript-eslint/no-type-alias': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
'@typescript-eslint/prefer-for-of': 'off', // I prefer for of, but I don't want to lint for it
'@typescript-eslint/sort-type-union-intersection-members': 'off',
'@typescript-eslint/typedef': 'off',
},
},
],
}