-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbase.js
More file actions
138 lines (135 loc) · 5.01 KB
/
base.js
File metadata and controls
138 lines (135 loc) · 5.01 KB
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
import { defineConfig } from 'eslint/config';
import cheminfoBase from 'eslint-config-cheminfo/base';
import tseslint from 'typescript-eslint';
export default defineConfig(cheminfoBase, {
name: 'cheminfo/typescript/rules',
files: ['**/*.{ts,tsx,cts,mts}'],
extends: [
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
parserOptions: {
projectService: true,
warnOnUnsupportedTypeScriptVersion: false,
},
},
rules: {
//region specific rules of typescript-eslint
// https://typescript-eslint.io/rules/
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
readonly: 'array-simple',
},
],
'@typescript-eslint/consistent-type-imports': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
// Too noisy for now.
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-deprecated': 'warn',
// Empty interfaces are common (React component props that extend others, AdonisJS default configs).
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': [
'error',
{
ignoreVoid: true,
},
],
// Only affects special edge cases.
'@typescript-eslint/no-invalid-void-type': 'off',
/**
* @see https://typescript-eslint.io/rules/no-redundant-type-constituents/
* > primitive types such as string "override" any of their literal types such as ""
*
* But `'literal' | string`
* can be use-full to suggest auto-complete to IDE about known and prevalent literals but accepts other strings
*/
'@typescript-eslint/no-redundant-type-constituents': 'off',
// Problematic when doing checks with array elements or values from records.
'@typescript-eslint/no-unnecessary-condition': 'off',
// TODO: enable no-unsafe rules when we are ready to ban `any` everywhere.
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-useless-empty-export': 'error',
// Clashes with no-non-null-assertion.
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-enum-initializers': 'error',
// TODO: enable when we are ready for it.
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/require-array-sort-compare': 'error',
// We consider it valid to use `async` without `await` in some cases.
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
// TODO: remove allowAny when we are ready.
{ allowAny: true },
],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
// It is useful to split signatures for readability and documentation.
'@typescript-eslint/unified-signatures': 'off',
//endregion
//region rules from eslint override by typescript-eslint
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'error',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'warn',
'no-loop-func': 'off',
'@typescript-eslint/no-loop-func': 'error',
// TypeScript handles this: https://typescript-eslint.io/rules/no-redeclare/
'no-redeclare': 'off',
// no-unreachable is disabled by the typescript-eslint plugin, because it can be checked by the TypeScript compiler.
// But we re-enable here it because treating it as an error requires setting `allowUnreachableCode` to false in the compiler options.
'no-unreachable': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['typeLike'],
format: ['PascalCase'],
},
{
selector: ['variable', 'typeProperty'],
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allowSingleOrDouble',
},
{
selector: ['function', 'typeMethod'],
format: ['camelCase', 'PascalCase'],
},
{
selector: [
'method',
'classProperty',
'classMethod',
'parameterProperty',
'accessor',
],
format: ['camelCase'],
leadingUnderscore: 'allowSingleOrDouble',
},
{
selector: [
'objectLiteralProperty',
'objectLiteralMethod',
'enumMember',
],
format: null,
},
],
//endregion
},
});