/
index.ts
115 lines (108 loc) · 4.66 KB
/
index.ts
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
import { rules as standardRules } from 'eslint-config-standard/eslintrc.json'
const equivalents = [
'brace-style',
'indent',
'no-array-constructor',
'no-throw-literal',
'no-unused-vars',
'no-unused-expressions',
'no-useless-constructor',
'quotes',
'space-before-function-paren'
] as const
function fromEntries<T> (iterable: Array<[string, T]>): { [key: string]: T } {
return [...iterable].reduce<{ [key: string]: T }>((obj, [key, val]) => {
obj[key] = val
return obj
}, {})
}
export = {
extends: 'eslint-config-standard',
plugins: ['@typescript-eslint'],
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
rules: {
// TypeScript has this functionality by default:
'no-undef': 'off',
// Incompatible with TypeScript function overloads:
'no-duplicate-class-members': 'off',
// Rules replaced by @typescript-eslint versions:
...fromEntries(equivalents.map((name) => [name, 'off'])),
camelcase: 'off',
'default-param-last': 'off',
'no-use-before-define': 'off',
// @typescript-eslint versions of Standard.js rules:
...fromEntries(equivalents.map((name) => [`@typescript-eslint/${name}`, standardRules[name]])),
'@typescript-eslint/no-use-before-define': ['error', {
functions: false,
classes: false,
enums: false,
variables: false,
typedefs: false // Only the TypeScript rule has this option.
}],
// Rules exclusive to Standard TypeScript:
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/camelcase': ['error', { properties: 'never', genericType: 'always' }],
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never'
}
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/explicit-function-return-type': ['error', {
allowExpressions: true,
allowHigherOrderFunctions: true,
allowTypedFunctionExpressions: true,
allowDirectConstAssertionInArrowFunctions: true
}],
'@typescript-eslint/member-delimiter-style': [
'error',
{
multiline: { delimiter: 'none' },
singleline: { delimiter: 'comma', requireLast: false }
}
],
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-empty-function': ['error', {
allow: [
'protected-constructors',
'private-constructors'
]
}],
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true }],
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': ['error', { ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false }],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': ['error', { checkCompoundAssignments: true }],
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/triple-slash-reference': ['error', { lib: 'never', path: 'never', types: 'never' }],
'@typescript-eslint/type-annotation-spacing': 'error'
}
}
]
}