generated from materya/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
typescript.js
116 lines (104 loc) · 3.04 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
module.exports = {
extends: [
'./index.js',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'import',
],
overrides: [
// Enable rules specifically for Typescript files
{
files: ['*.ts'],
rules: {
// Disable js rules in favor of specific TS ones
camelcase: 'off',
'no-shadow': 'off',
'no-underscore-dangle': 'off',
'no-unused-vars': 'off',
// Incompatible rules with TS
'import/named': 'off',
// Enforce return type
'@typescript-eslint/explicit-function-return-type': ['error'],
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.mjs', '.ts', '.d.ts'],
},
},
},
},
],
settings: {
},
rules: {
// Disable rules for a mixed js/ts codebase - see `overrides` parameter
'@typescript-eslint/explicit-function-return-type': 'off',
// Simplify notation, removing useless delimiter
'@typescript-eslint/member-delimiter-style': ['error', {
multiline: { delimiter: 'none' },
singleline: { delimiter: 'semi', requireLast: false },
}],
// Enforce no-explicit-any as an error
'@typescript-eslint/no-explicit-any': ['error', {
fixToUnknown: false,
ignoreRestArgs: false,
}],
// By default a warning. That's a code smell, forcing an error instead.
'@typescript-eslint/no-non-null-assertion': 'error',
/* unused vars:
* - add the option to explicitly annotated unused vars
*/
'@typescript-eslint/no-unused-vars': ['error', {
args: 'all',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
}],
// incompatible no-shadow rule with ts, replace with a specific ts one
'@typescript-eslint/no-shadow': ['error'],
/**
* Naming convention rules:
*
* - default to `strictCamelCase`.
* - match `@typescript-eslint/no-unused-vars` rule for unused vars with
* a leading underscore.
* - `StrictPascalCase` for `typeLike` declarations.
*/
'@typescript-eslint/naming-convention': ['error',
{
format: ['strictCamelCase'],
leadingUnderscore: 'forbid',
selector: 'default',
trailingUnderscore: 'forbid',
},
// Match unused vars rule with leading underscore allowed
{
format: ['strictCamelCase'],
leadingUnderscore: 'allow',
modifiers: ['unused'],
selector: ['variable', 'parameter'],
trailingUnderscore: 'forbid',
},
/**
* Special members convention as PascalCase
*/
{
format: ['StrictPascalCase'],
selector: ['enumMember', 'typeLike'],
},
/**
* Allow snake_case on destructuring
*/
// {
// format: ['strictCamelCase', 'snake_case'],
// modifiers: ['destructured'],
// selector: 'variable',
// },
],
},
}