-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
122 lines (120 loc) · 3.6 KB
/
index.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
module.exports = {
env: {
es6: true,
},
extends: [
'eslint-config-salesforce',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'eslint-config-prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
'./packages/**/tsconfig.json',
'./packages/**/test/tsconfig.json',
'./tsconfig.json',
'./test/tsconfig.json',
],
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'eslint-plugin-import', 'eslint-plugin-jsdoc', 'unicorn'],
rules: {
'unicorn/prefer-node-protocol': 'error',
'unicorn/numeric-separators-style': 'warn',
// turn the rule off everywhere. Then, in overrides, turn it on for just src
'import/no-extraneous-dependencies': ['off'],
// Override @typescript-eslint/recommended
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
// true generally (so we get it in /test), we override it to false for src lower down
allowNullish: true,
allowBoolean: true,
allowNumber: true,
},
],
// Custom @typescript-eslint
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
},
],
'@typescript-eslint/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/return-await': 'error',
// turning off the base rule is recommended by ts-eslint
'no-return-await': 'off',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/quotes': [
'error',
'single',
{
avoidEscape: true,
},
],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unified-signatures': 'error',
'no-shadow': 'off',
},
ignorePatterns: ['*.js'],
overrides: [
{
// put stricter rules you only want to apply to production code here
files: ['src/**'],
rules: {
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNullish: false,
allowBoolean: true,
allowNumber: true,
},
],
'import/no-extraneous-dependencies': [
'error',
{
includeTypes: false,
devDependencies: false,
peerDependencies: false,
bundledDependencies: false,
optionalDependencies: false,
},
],
},
},
],
};