@modern-js-app/eslint-config 1.2.3 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1 +1,4 @@
1
- module.exports = { extends: ['./eslintrc.prettier.js'] };
1
+ module.exports = {
2
+ // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
3
+ extends: ['./base.js', './ts', './ts.withType.js', './prettier'],
4
+ };
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/lite.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
3
+ extends: ['./base.js', './ts.js', './prettier'],
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js-app/eslint-config",
3
- "version": "1.2.3",
3
+ "version": "1.2.6",
4
4
  "description": "The meta-framework suite designed from scratch for frontend-focused modern web development.",
5
5
  "homepage": "https://modernjs.dev",
6
6
  "bugs": "https://github.com/modern-js-dev/modern.js/issues",
@@ -15,8 +15,8 @@
15
15
  "peerDependencies": {
16
16
  "@babel/eslint-parser": "^7.15.0",
17
17
  "@babel/eslint-plugin": "^7.13.10",
18
- "@typescript-eslint/eslint-plugin": "^5.12.1",
19
- "@typescript-eslint/parser": "^5.12.1",
18
+ "@typescript-eslint/eslint-plugin": "^5.17.0",
19
+ "@typescript-eslint/parser": "^5.17.0",
20
20
  "eslint": "^7.32.0",
21
21
  "eslint-config-prettier": "^8.3.0",
22
22
  "eslint-import-resolver-webpack": "^0.13.1",
@@ -25,14 +25,14 @@
25
25
  "eslint-plugin-import": "^2.18.2",
26
26
  "eslint-plugin-markdown": "^2.2.0",
27
27
  "eslint-plugin-node": "^11.1.0",
28
- "eslint-plugin-prettier": "^3.4.1",
28
+ "eslint-plugin-prettier": "^4.0.0",
29
29
  "eslint-plugin-promise": "^5.1.0",
30
30
  "eslint-plugin-react": "^7.24.0",
31
31
  "eslint-plugin-react-hooks": "^4.2.0",
32
32
  "prettier": "^2.5.1"
33
33
  },
34
34
  "dependencies": {
35
- "@modern-js/babel-preset-app": "^1.2.0"
35
+ "@modern-js/babel-preset-app": "^1.2.5"
36
36
  },
37
37
  "devDependencies": {
38
38
  "eslint": "^7.32.0",
package/prettier.js ADDED
@@ -0,0 +1,26 @@
1
+ module.exports = {
2
+ // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
3
+ extends: [
4
+ // https://github.com/prettier/eslint-plugin-prettier
5
+ 'plugin:prettier/recommended',
6
+ ],
7
+ rules: {
8
+ /**
9
+ * Enable some rules disabled by eslint-config-prettier
10
+ * @Warning : rules bellow can conflict with Prettier in some situations
11
+ */
12
+ // https://github.com/prettier/eslint-config-prettier#curly
13
+ curly: 'error',
14
+ // https://github.com/prettier/eslint-config-prettier#no-tabs
15
+ 'no-tabs': 'error',
16
+ },
17
+ overrides: [
18
+ // ignore auto-generated css module declarations
19
+ {
20
+ files: ['*.css.d.ts'],
21
+ rules: {
22
+ 'prettier/prettier': 'off',
23
+ },
24
+ },
25
+ ],
26
+ };
package/ts.js ADDED
@@ -0,0 +1,410 @@
1
+ const { jsExtensions } = require('./utils');
2
+
3
+ module.exports = {
4
+ overrides: [
5
+ {
6
+ files: ['*.ts', '*.d.ts', '*.tsx'],
7
+
8
+ /*
9
+ * https://eslint.org/blog/2019/01/future-typescript-eslint
10
+ * https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
11
+ */
12
+ parser: '@typescript-eslint/parser',
13
+ // https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
14
+ plugins: [
15
+ '@typescript-eslint',
16
+ // 'tsdoc'
17
+ ],
18
+ // @BUG
19
+ extends: ['plugin:@typescript-eslint/recommended'],
20
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/config/typescript.js
21
+ settings: {
22
+ 'import/external-module-folders': [
23
+ 'node_modules',
24
+ 'node_modules/@types',
25
+ ],
26
+ 'import/parsers': {
27
+ '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
28
+ },
29
+ 'import/resolver': { node: { extensions: jsExtensions } },
30
+ },
31
+ rules: {
32
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/config/typescript.js
33
+ 'import/named': 'off',
34
+ camelcase: 'off',
35
+ indent: 'off',
36
+ 'no-unused-vars': 'off',
37
+ 'no-use-before-define': 'off',
38
+ // type A = { foo: string; }; export { A };
39
+ 'no-undef': 'off',
40
+ 'prefer-named-capture-group': 'off',
41
+ 'no-useless-constructor': 'off',
42
+ 'no-array-constructor': 'off',
43
+ 'func-call-spacing': 'off',
44
+ // @BUG no ignore
45
+ 'no-magic-numbers': 'off',
46
+ semi: 'off',
47
+ 'no-empty-function': 'off',
48
+ 'equire-await': 'off',
49
+ 'require-await': 'off',
50
+ 'one-var': ['error', 'never'],
51
+ // 'jsdoc/no-types': 'error',
52
+ 'react/require-default-props': 'off',
53
+ // 'jsdoc/check-tag-names': 'off',
54
+ // https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
55
+ // 'tsdoc/syntax': 'warn',
56
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md
57
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
58
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md
59
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
60
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md
61
+ '@typescript-eslint/array-type': 'off',
62
+
63
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-ts-comment.md
64
+ '@typescript-eslint/ban-ts-comment': [
65
+ 'error',
66
+ {
67
+ 'ts-expect-error': true,
68
+ 'ts-ignore': true,
69
+ 'ts-nocheck': true,
70
+ 'ts-check': false,
71
+ },
72
+ ],
73
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
74
+ '@typescript-eslint/ban-types': 'error',
75
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-ts-comment.md
76
+ '@typescript-eslint/ban-tslint-comment': 'error',
77
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/class-literal-property-style.md
78
+ '@typescript-eslint/class-literal-property-style': ['error', 'fields'],
79
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md
80
+ '@typescript-eslint/consistent-indexed-object-style': 'off',
81
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md
82
+ '@typescript-eslint/consistent-type-assertions': 'error',
83
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md
84
+ '@typescript-eslint/consistent-type-definitions': 'off',
85
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-imports.md
86
+ '@typescript-eslint/consistent-type-imports': 'off',
87
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
88
+ '@typescript-eslint/explicit-function-return-type': 'off',
89
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md
90
+ '@typescript-eslint/explicit-member-accessibility': 'off',
91
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md
92
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
93
+ '@typescript-eslint/indent': [
94
+ 'error',
95
+ 2,
96
+ {
97
+ SwitchCase: 1,
98
+ VariableDeclarator: 'first',
99
+ outerIIFEBody: 0,
100
+ MemberExpression: 1,
101
+ FunctionDeclaration: { parameters: 'first' },
102
+ FunctionExpression: { parameters: 'first' },
103
+ CallExpression: { arguments: 'first' },
104
+ ArrayExpression: 1,
105
+ ObjectExpression: 1,
106
+ ImportDeclaration: 1,
107
+ flatTernaryExpressions: false,
108
+ },
109
+ ],
110
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md
111
+ '@typescript-eslint/member-delimiter-style': [
112
+ 'error',
113
+ {
114
+ multiline: {
115
+ delimiter: 'semi',
116
+ requireLast: true,
117
+ },
118
+ singleline: {
119
+ delimiter: 'semi',
120
+ requireLast: true,
121
+ },
122
+ },
123
+ ],
124
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md
125
+ '@typescript-eslint/member-ordering': [
126
+ 'error',
127
+ {
128
+ default: [
129
+ 'public-static-field',
130
+ 'protected-static-field',
131
+ 'private-static-field',
132
+ 'static-field',
133
+ 'public-static-method',
134
+ 'protected-static-method',
135
+ 'private-static-method',
136
+ 'static-method',
137
+ 'public-instance-field',
138
+ 'protected-instance-field',
139
+ 'private-instance-field',
140
+ 'instance-field',
141
+ 'public-field',
142
+ 'protected-field',
143
+ 'private-field',
144
+ 'field',
145
+ 'constructor',
146
+ // 'public-instance-method',
147
+ // 'protected-instance-method',
148
+ // 'private-instance-method',
149
+ 'instance-method',
150
+ // 'public-method',
151
+ // 'protected-method',
152
+ // 'private-method',
153
+ 'method',
154
+ ],
155
+ },
156
+ ],
157
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/method-signature-style.md
158
+ '@typescript-eslint/method-signature-style': 'error',
159
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
160
+ '@typescript-eslint/naming-convention': [
161
+ 'error',
162
+ {
163
+ selector: 'default',
164
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
165
+ leadingUnderscore: 'allowSingleOrDouble',
166
+ trailingUnderscore: 'allowSingleOrDouble',
167
+ },
168
+ // https://typescript-eslint.io/rules/naming-convention/#ignore-properties-that-require-quotes
169
+ {
170
+ selector: [
171
+ 'classProperty',
172
+ 'objectLiteralProperty',
173
+ 'typeProperty',
174
+ 'classMethod',
175
+ 'objectLiteralMethod',
176
+ 'typeMethod',
177
+ 'accessor',
178
+ 'enumMember',
179
+ ],
180
+ format: null,
181
+ modifiers: ['requiresQuotes'],
182
+ },
183
+ {
184
+ selector: 'variable',
185
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
186
+ leadingUnderscore: 'allowSingleOrDouble',
187
+ trailingUnderscore: 'allowSingleOrDouble',
188
+ },
189
+
190
+ {
191
+ selector: 'typeLike',
192
+ format: ['PascalCase'],
193
+ },
194
+ ],
195
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
196
+ '@typescript-eslint/no-array-constructor': 'error',
197
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-interface.md
198
+ '@typescript-eslint/no-empty-interface': 'error',
199
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md
200
+ // @TODO disable?
201
+ '@typescript-eslint/no-explicit-any': 'off',
202
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extraneous-class.md
203
+ '@typescript-eslint/no-extraneous-class': 'error',
204
+ // https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
205
+ '@typescript-eslint/no-implicit-any-catch': 'off',
206
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md
207
+ '@typescript-eslint/no-inferrable-types': [
208
+ 'error',
209
+ { ignoreProperties: true },
210
+ ],
211
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-misused-new.md
212
+ '@typescript-eslint/no-misused-new': 'error',
213
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-namespace.md
214
+ '@typescript-eslint/no-namespace': 'error',
215
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md
216
+ '@typescript-eslint/no-confusing-non-null-assertion': 'error',
217
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md
218
+ '@typescript-eslint/no-confusing-void-expression': 'off',
219
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md
220
+ // @feedback 在 middleware 下,如果有些参数是 optional 的,会在上一层被拦截掉,下一层一定会有这个参数
221
+ '@typescript-eslint/no-non-null-assertion': 'off',
222
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-non-null-assertion.md
223
+ '@typescript-eslint/no-extra-non-null-assertion': 'error',
224
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-parameter-properties.md
225
+ '@typescript-eslint/no-parameter-properties': 'error',
226
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-require-imports.md
227
+ '@typescript-eslint/no-require-imports': 'error',
228
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-this-alias.md
229
+ '@typescript-eslint/no-this-alias': [
230
+ 'error',
231
+ { allowDestructuring: true },
232
+ ],
233
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-type-alias.md
234
+ '@typescript-eslint/no-type-alias': 'off',
235
+
236
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md
237
+ '@typescript-eslint/no-unnecessary-condition': 'off',
238
+
239
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md
240
+ '@typescript-eslint/no-unnecessary-type-constraint': 'error',
241
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
242
+ '@typescript-eslint/no-unused-vars': [
243
+ 'error',
244
+ {
245
+ vars: 'all',
246
+ args: 'after-used',
247
+ ignoreRestSiblings: true,
248
+ argsIgnorePattern: '^_',
249
+ caughtErrors: 'none',
250
+ },
251
+ ],
252
+ '@babel/no-unused-expressions': 'off',
253
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
254
+ '@typescript-eslint/no-unused-expressions': [
255
+ 'error',
256
+ {
257
+ allowShortCircuit: true,
258
+ allowTernary: false,
259
+ allowTaggedTemplates: true,
260
+ },
261
+ ],
262
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
263
+ '@typescript-eslint/no-use-before-define': [
264
+ 'error',
265
+ {
266
+ functions: false,
267
+ classes: false,
268
+ variables: false,
269
+ },
270
+ ],
271
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
272
+ '@typescript-eslint/no-useless-constructor': 'error',
273
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-var-requires.md
274
+ '@typescript-eslint/no-var-requires': 'error',
275
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-as-const.md
276
+ '@typescript-eslint/prefer-as-const': 'error',
277
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md
278
+ '@typescript-eslint/prefer-enum-initializers': 'off',
279
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-for-of.md
280
+ '@typescript-eslint/prefer-for-of': 'error',
281
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-function-type.md
282
+ '@typescript-eslint/prefer-function-type': 'error',
283
+
284
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md
285
+ '@typescript-eslint/prefer-namespace-keyword': 'off',
286
+
287
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md
288
+ '@typescript-eslint/prefer-literal-enum-member': 'error',
289
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md
290
+ '@typescript-eslint/prefer-optional-chain': 'error',
291
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md
292
+ '@typescript-eslint/prefer-nullish-coalescing': 'off',
293
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md
294
+ '@typescript-eslint/prefer-readonly-parameter-types': 'off',
295
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md
296
+ '@typescript-eslint/prefer-reduce-type-parameter': 'off',
297
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md
298
+ '@typescript-eslint/prefer-ts-expect-error': 'error',
299
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/promise-function-async.md
300
+ // @BUG
301
+ '@typescript-eslint/promise-function-async': 'off',
302
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/require-array-sort-compare.md
303
+ '@typescript-eslint/require-array-sort-compare': 'off',
304
+
305
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/triple-slash-reference.md
306
+ '@typescript-eslint/triple-slash-reference': 'off',
307
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/type-annotation-spacing.md
308
+ '@typescript-eslint/type-annotation-spacing': [
309
+ 'error',
310
+ {
311
+ before: false,
312
+ after: true,
313
+ },
314
+ ],
315
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unified-signatures.md
316
+ '@typescript-eslint/unified-signatures': 'error',
317
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
318
+ '@typescript-eslint/func-call-spacing': 'off',
319
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md
320
+ '@typescript-eslint/no-magic-numbers': 'off',
321
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
322
+ '@typescript-eslint/semi': ['error', 'always'],
323
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
324
+ '@typescript-eslint/no-empty-function': ['error', { allow: [] }],
325
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md
326
+ '@typescript-eslint/strict-boolean-expressions': 'off',
327
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md
328
+ '@typescript-eslint/typedef': [
329
+ 'error',
330
+ {
331
+ arrayDestructuring: false,
332
+ arrowParameter: false,
333
+ memberVariableDeclaration: true,
334
+ objectDestructuring: false,
335
+ parameter: false,
336
+ propertyDeclaration: true,
337
+ variableDeclaration: false,
338
+ variableDeclarationIgnoreFunction: true,
339
+ },
340
+ ],
341
+
342
+ 'brace-style': 'off',
343
+ '@typescript-eslint/brace-style': [
344
+ 'error',
345
+ '1tbs',
346
+ { allowSingleLine: true },
347
+ ],
348
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-dangle.md
349
+ 'comma-dangle': 'off',
350
+ '@typescript-eslint/comma-dangle': 'off',
351
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-spacing.md
352
+ 'comma-spacing': 'off',
353
+ '@typescript-eslint/comma-spacing': [
354
+ 'error',
355
+ {
356
+ before: false,
357
+ after: true,
358
+ },
359
+ ],
360
+
361
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md
362
+ 'keyword-spacing': 'off',
363
+ '@typescript-eslint/keyword-spacing': [
364
+ 'error',
365
+ {
366
+ before: true,
367
+ after: true,
368
+ },
369
+ ],
370
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-between-class-members.md
371
+ 'lines-between-class-members': 'off',
372
+ '@typescript-eslint/lines-between-class-members': ['error', 'always'],
373
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dupe-class-members.md
374
+ 'no-dupe-class-members': 'off',
375
+ '@typescript-eslint/no-dupe-class-members': 'error',
376
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
377
+ 'no-extra-parens': 'off',
378
+ '@typescript-eslint/no-extra-parens': [
379
+ 'error',
380
+ 'all',
381
+ { ignoreJSX: 'multi-line' },
382
+ ],
383
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-semi.md
384
+ 'no-extra-semi': 'off',
385
+ '@typescript-eslint/no-extra-semi': 'error',
386
+
387
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loop-func.md
388
+ 'no-loop-func': 'off',
389
+ '@typescript-eslint/no-loop-func': 'error',
390
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
391
+ 'no-redeclare': 'off',
392
+ '@typescript-eslint/no-redeclare': ['error', { builtinGlobals: true }],
393
+
394
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-before-function-paren.md
395
+ 'space-before-function-paren': 'off',
396
+ '@typescript-eslint/space-before-function-paren': [
397
+ 'error',
398
+ {
399
+ anonymous: 'always',
400
+ named: 'never',
401
+ asyncArrow: 'always',
402
+ },
403
+ ],
404
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-infix-ops.md
405
+ 'space-infix-ops': 'off',
406
+ '@typescript-eslint/space-infix-ops': 'error',
407
+ },
408
+ },
409
+ ],
410
+ };
package/ts.withType.js ADDED
@@ -0,0 +1,57 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ['*.ts', '*.d.ts', '*.tsx'],
5
+ // modern.config.ts is usually not included in tsconfig.json
6
+ excludedFiles: ['modern.config.ts'],
7
+ parserOptions: {
8
+ ecmaFeatures: { jsx: true },
9
+ // don't set tsconfigRootDir, using the path relative to the cwd
10
+ project: ['./tsconfig.json'],
11
+ },
12
+ rules: {
13
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/await-thenable.md
14
+ '@typescript-eslint/await-thenable': 'error',
15
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-for-in-array.md
16
+ '@typescript-eslint/no-for-in-array': 'error',
17
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md
18
+ 'no-implied-eval': 'off',
19
+ '@typescript-eslint/no-implied-eval': 'error',
20
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-misused-promises.md
21
+ '@typescript-eslint/no-misused-promises': [
22
+ 'error',
23
+ { checksVoidReturn: false },
24
+ ],
25
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
26
+ '@typescript-eslint/no-unnecessary-type-assertion': 'error',
27
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-base-to-string.md
28
+ '@typescript-eslint/no-base-to-string': 'error',
29
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md
30
+ '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
31
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md
32
+ '@typescript-eslint/no-unnecessary-qualifier': 'error',
33
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin//docs/rules/no-unnecessary-type-arguments.md
34
+ '@typescript-eslint/no-unnecessary-type-arguments': 'error',
35
+ // https://github.com/typescript-eslint/typescript-eslint/pull/294
36
+ '@typescript-eslint/prefer-includes': 'error',
37
+ // https://github.com/typescript-eslint/typescript-eslint/pull/289
38
+ '@typescript-eslint/prefer-string-starts-ends-with': 'error',
39
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md
40
+ '@typescript-eslint/prefer-regexp-exec': 'error',
41
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-readonly.md
42
+ '@typescript-eslint/prefer-readonly': 'error',
43
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md
44
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
45
+ // https://github.com/typescript-eslint/typescript-eslint/blob/55eb0cfac20ccbc2e954083dd554dbcfcbed64fb/packages/eslint-plugin/docs/rules/return-await.md
46
+ 'no-return-await': 'off',
47
+ '@typescript-eslint/return-await': 'error',
48
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md
49
+ 'dot-notation': 'off',
50
+ '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
51
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md
52
+ 'no-throw-literal': 'off',
53
+ '@typescript-eslint/no-throw-literal': 'error',
54
+ },
55
+ },
56
+ ],
57
+ };
@@ -1,83 +0,0 @@
1
- module.exports = {
2
- // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
3
- extends: [
4
- './eslintrc.js',
5
- // https://www.npmjs.com/package/eslint-config-prettier
6
- // https://github.com/prettier/eslint-config-prettier/blob/master/index.js#L14
7
- 'prettier',
8
- ],
9
- env: {
10
- commonjs: false,
11
- browser: true,
12
- node: false,
13
- },
14
- rules: {
15
- // https://github.com/prettier/eslint-config-prettier#curly
16
- curly: 'error',
17
- // https://github.com/prettier/eslint-config-prettier#max-len
18
- 'max-len': [
19
- 'error',
20
- {
21
- code: 80,
22
- tabWidth: 4,
23
- ignoreComments: true,
24
- ignoreTrailingComments: false,
25
- ignoreUrls: true,
26
- ignoreStrings: true,
27
- ignoreTemplateLiterals: true,
28
- ignoreRegExpLiterals: true,
29
- },
30
- ],
31
- // https://github.com/prettier/eslint-config-prettier#no-confusing-arrow
32
- 'no-confusing-arrow': 'off',
33
- // https://github.com/prettier/eslint-config-prettier#no-mixed-operators
34
- 'no-mixed-operators': 'off',
35
- // https://github.com/prettier/eslint-config-prettier#no-tabs
36
- 'no-tabs': 'error',
37
- // https://github.com/prettier/eslint-config-prettier#quotes
38
- quotes: 'off',
39
- },
40
- // https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
41
- // https://eslint.org/docs/user-guide/migrating-to-6.0.0#-overrides-in-an-extended-config-file-can-now-be-overridden-by-a-parent-config-file
42
- overrides: [
43
- {
44
- files: ['*.ts', '*.tsx'],
45
- rules: {
46
- '@typescript-eslint/indent': 'off',
47
- '@typescript-eslint/member-delimiter-style': 'off',
48
- '@typescript-eslint/type-annotation-spacing': 'off',
49
- },
50
- },
51
- {
52
- files: ['*.test.*', '__test__/*'],
53
- env: {
54
- mocha: true,
55
- jest: true,
56
- },
57
- rules: {
58
- 'no-unused-expressions': 'off',
59
- '@babel/no-unused-expressions': 'off',
60
- },
61
- },
62
- {
63
- files: ['*.worker.*'],
64
- env: { worker: true },
65
- },
66
- {
67
- files: ['**/pages/**/_*', '**/pages/**/\\[**'],
68
- rules: {
69
- 'filenames/match-regex': 'off',
70
- 'filenames/match-exported': 'off',
71
- },
72
- },
73
- // ignore auto-generated css module declarations
74
- {
75
- files: ['*.css.d.ts'],
76
- rules: {
77
- 'pre/match-regex': 'off',
78
- 'filenames/match-exported': 'off',
79
- 'prettier/prettier': 'off',
80
- },
81
- },
82
- ],
83
- };