-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
143 lines (140 loc) · 5.05 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
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./tsconfig.json',
'./test/tsconfig.json'
],
},
// Ignoring js files (such as this one) since they seem to conflict with rules that require typing info
ignorePatterns: [ '*.js' ],
plugins: [
'tsdoc',
'import',
'unused-imports',
],
extends: [
'es/node',
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended'
],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
// Below taken from https://github.com/comake/community-server/blob/main/.eslintrc.js
// There are valid typing reasons to have one or the other
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/lines-between-class-members': [ 'error', { exceptAfterSingleLine: true }],
'@typescript-eslint/no-empty-interface': 'off',
// Breaks with default void in AsyncHandler 2nd generic
'@typescript-eslint/no-invalid-void-type': 'off',
// Problems with optional parameters
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/promise-function-async': [ 'error', { checkArrowFunctions: false } ],
'@typescript-eslint/space-before-function-paren': [ 'error', 'never' ],
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off',
// Conflicts with functions from interfaces that sometimes don't require `this`
'class-methods-use-this': 'off',
'comma-dangle': [ 'error', 'always-multiline' ],
'dot-location': [ 'error', 'property' ],
'eslint-comments/disable-enable-pair': 'off',
// Allow declaring overloads in TypeScript (https://eslint.org/docs/rules/func-style)
'func-style': [ 'error', 'declaration' ],
'generator-star-spacing': [ 'error', 'after' ],
// Conflicts with padded-blocks
'lines-around-comment': 'off',
'lines-between-class-members': [ 'error', 'always', { exceptAfterSingleLine: true }],
'max-len': [ 'error', { code: 120, ignoreUrls: true }],
// Used for RDF constants
'new-cap': 'off',
// Necessary in constructor overloading
'no-param-reassign': 'off',
// Checked by @typescript-eslint/no-redeclare
'no-redeclare': 'off',
// Conflicts with external libraries
'no-underscore-dangle': 'off',
// Already checked by @typescript-eslint/no-unused-vars
'no-unused-vars': 'off',
'padding-line-between-statements': 'off',
'prefer-named-capture-group': 'off',
// Already generated by TypeScript
strict: 'off',
'tsdoc/syntax': 'error',
'unicorn/catch-error-name': 'off',
'unicorn/import-index': 'off',
'unicorn/import-style': 'off',
// The next 2 some functional programming paradigms
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/numeric-separators-style': 'off',
// At function only supported in Node v16.6.0
'unicorn/prefer-at': 'off',
// Does not make sense for more complex cases
'unicorn/prefer-object-from-entries': 'off',
// Only supported in Node v15
'unicorn/prefer-string-replace-all' : 'off',
// Can get ugly with large single statements
'unicorn/prefer-ternary': 'off',
'yield-star-spacing': [ 'error', 'after' ],
// Need to use the typescript version of this rule to support overloading
"no-dupe-class-members": "off",
"@typescript-eslint/no-dupe-class-members": ["error"],
// Naming conventions
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: [ 'camelCase' ],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: 'variable',
format: [ 'camelCase', 'UPPER_CASE' ],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: 'typeLike',
format: [ 'PascalCase' ],
},
{
selector: [ 'typeParameter' ],
format: [ 'PascalCase' ],
prefix: [ 'T' ],
},
],
// Import
'@typescript-eslint/consistent-type-imports': [ 'error', { prefer: 'type-imports' }],
// Disabled in favor of eslint-plugin-import
'sort-imports': 'off',
'import/order': [ 'error', {
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
}],
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-named-as-default': 'off',
// Doesn't work with type imports
'no-duplicate-imports': 'off',
'unused-imports/no-unused-imports-ts': 'error',
// Comake code style preferences
'operator-linebreak': ["error", "after", { "overrides": { "?": "before", ":": "before" } }],
},
overrides: [
{
files: '*.js',
parser: 'espree',
},
],
};