-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·162 lines (151 loc) · 5.57 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* eslint-disable @typescript-eslint/naming-convention */
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:@typescript-eslint/strict',
'eslint-config-prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
},
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
},
},
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
},
rules: {
// @typescript-eslint overrides that work better than ESLint.
// The base rule needs to be disabled to prevent false positives.
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
camelcase: 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase', 'UPPER_CASE', 'PascalCase', 'snake_case'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase', 'snake_case'],
},
{
selector: 'parameter',
format: ['camelCase', 'UPPER_CASE', 'PascalCase', 'snake_case'],
leadingUnderscore: 'allow',
},
{
// Matches: class, interface, typeAlias, enum, typeParameter
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dupe-class-members.md
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': ['error'],
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loop-func.md
'no-loop-func': 'off',
'@typescript-eslint/no-loop-func': 'error',
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': ['error'],
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': ['error'],
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
// Override Airbnb 'import/extensions' rule. Add 'ts' and 'tsx'.
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
mjs: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
// Override Airbnb 'import/no-extraneous-dependencies' rule. Add 'ts' and 'tsx'.
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'test/**',
'tests/**',
'spec/**',
'**/__tests__/**',
'**/__mocks__/**',
'test.{js,jsx,ts,tsx}',
'test-*.{js,jsx,ts,tsx}',
'**/*{.,_}{test,spec}.{js,jsx,ts,tsx}',
'**/jest.config.js',
'**/jest.setup.js',
'**/vue.config.js',
'**/webpack.config.js',
'**/webpack.config.*.js',
'**/rollup.config.js',
'**/rollup.config.*.js',
'**/gulpfile.js',
'**/gulpfile.*.js',
'**/Gruntfile{,.js}',
'**/protractor.conf.js',
'**/protractor.conf.*.js',
'**/karma.conf.js',
],
optionalDependencies: false,
},
],
// See https://github.com/typescript-eslint/typescript-eslint/issues/7227
'@typescript-eslint/no-invalid-void-type': 'off',
},
overrides: [
{
// Enable the rule specifically for TypeScript files
files: ['*.ts', '*.tsx'],
rules: {
// Required for mixed JS/TS code bases - https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
'@typescript-eslint/explicit-function-return-type': ['error'],
// Disable the following rules since the TypeScript
// compiler does it.
'constructor-super': 'off',
'getter-return': 'off',
'no-const-assign': 'off',
'no-dupe-args': 'off',
'no-dupe-keys': 'off',
'no-func-assign': 'off',
'no-new-symbol': 'off',
'no-obj-calls': 'off',
'no-this-before-super': 'off',
'no-undef': 'off',
'no-unreachable': 'off',
'no-unsafe-negation': 'off',
'valid-typeof': 'off',
'import/named': 'off',
'import/no-unresolved': 'off',
},
},
{
files: ['**/*.spec.js', '**/*.test.js', '**/tests-*.js', '**/*.spec.ts', '**/*.test.ts', '**/tests-*.ts'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
],
};