@naturalcycles/dev-lib 12.3.2 → 12.4.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [12.4.0](https://github.com/NaturalCycles/dev-lib/compare/v12.3.2...v12.4.0) (2021-09-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * refactor eslint.config to use `overrides` ([4aebe20](https://github.com/NaturalCycles/dev-lib/commit/4aebe206bd96c00cc9e017a77b3346c6c7c79312))
7
+
1
8
  ## [12.3.2](https://github.com/NaturalCycles/dev-lib/compare/v12.3.1...v12.3.2) (2021-09-17)
2
9
 
3
10
 
package/cfg/_cnst.js CHANGED
@@ -3,7 +3,7 @@ module.exports = {
3
3
  'src,scripts,e2e,docs,cfg,resources,.circleci,.github,public,static,components,content,layouts,pages,plugins,middleware,store',
4
4
  ],
5
5
  // ts,tsx,css,scss excluded, cause they need to run in special order (overlap between >1 tool):
6
- prettierExtensionsExclusive: 'js,jsx,json,md,graphql,yml,yaml,html,vue',
6
+ prettierExtensionsExclusive: 'js,jsx,json,md,graphql,yml,yaml,html',
7
7
  // everything that prettier supports:
8
8
  prettierExtensionsAll: 'ts,tsx,css,scss,js,jsx,json,md,graphql,yml,yaml,html,vue',
9
9
  stylelintExtensions: 'css,scss',
@@ -0,0 +1,293 @@
1
+ module.exports = {
2
+ rules: {
3
+ '@typescript-eslint/adjacent-overload-signatures': 2,
4
+ '@typescript-eslint/ban-ts-comment': 0,
5
+ '@typescript-eslint/ban-types': [
6
+ 2,
7
+ {
8
+ types: {
9
+ Object: {
10
+ message: 'Avoid using the `Object` type. Did you mean `object`?',
11
+ },
12
+ Boolean: {
13
+ message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
14
+ },
15
+ Number: {
16
+ message: 'Avoid using the `Number` type. Did you mean `number`?',
17
+ },
18
+ String: {
19
+ message: 'Avoid using the `String` type. Did you mean `string`?',
20
+ },
21
+ Symbol: {
22
+ message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
23
+ },
24
+ },
25
+ },
26
+ ],
27
+ '@typescript-eslint/consistent-type-assertions': 2,
28
+ '@typescript-eslint/consistent-type-definitions': 2,
29
+ '@typescript-eslint/naming-convention': [
30
+ 0,
31
+ {
32
+ // todo: clarify later, currently disabled
33
+ selector: 'default',
34
+ format: ['camelCase', 'UPPER_CASE'],
35
+ },
36
+ ],
37
+ '@typescript-eslint/no-array-constructor': 2,
38
+ '@typescript-eslint/no-empty-interface': 0, // too inconvenient
39
+ '@typescript-eslint/no-extra-non-null-assertion': 2,
40
+ '@typescript-eslint/no-extra-semi': 0, // prettier handles it
41
+ '@typescript-eslint/no-floating-promises': 2,
42
+ '@typescript-eslint/no-inferrable-types': [
43
+ 2,
44
+ {
45
+ ignoreParameters: true,
46
+ },
47
+ ],
48
+ '@typescript-eslint/no-misused-new': 2,
49
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 2,
50
+ '@typescript-eslint/no-this-alias': 0, // buggy
51
+ '@typescript-eslint/no-unused-expressions': 2,
52
+ '@typescript-eslint/prefer-as-const': 2,
53
+ '@typescript-eslint/prefer-for-of': 2,
54
+ '@typescript-eslint/prefer-function-type': 2,
55
+ '@typescript-eslint/prefer-namespace-keyword': 2,
56
+ '@typescript-eslint/promise-function-async': [
57
+ 2,
58
+ {
59
+ checkArrowFunctions: false,
60
+ checkFunctionDeclarations: true,
61
+ checkFunctionExpressions: true,
62
+ checkMethodDeclarations: true,
63
+ },
64
+ ],
65
+ '@typescript-eslint/triple-slash-reference': 2,
66
+ complexity: [
67
+ 2,
68
+ {
69
+ max: 30,
70
+ },
71
+ ],
72
+ 'constructor-super': 2,
73
+ curly: [2, 'multi-line'],
74
+ 'eol-last': 2,
75
+ eqeqeq: [2, 'smart'],
76
+ 'for-direction': 2,
77
+ 'getter-return': 2,
78
+ 'id-blacklist': [
79
+ 2,
80
+ 'any',
81
+ 'Number',
82
+ 'number',
83
+ 'String',
84
+ 'string',
85
+ 'Boolean',
86
+ 'boolean',
87
+ 'Undefined',
88
+ 'undefined',
89
+ ],
90
+ 'id-match': 2,
91
+ // "import/order": "error",
92
+ 'jsdoc/check-alignment': 2,
93
+ // "jsdoc/check-indentation": "error",
94
+ 'jsdoc/newline-after-description': 2,
95
+ 'no-array-constructor': 'off',
96
+ 'no-async-promise-executor': 2,
97
+ 'no-bitwise': 2,
98
+ 'no-caller': 2,
99
+ 'no-case-declarations': 2,
100
+ 'no-class-assign': 2,
101
+ 'no-compare-neg-zero': 2,
102
+ 'no-cond-assign': 2,
103
+ 'no-const-assign': 2,
104
+ 'no-constant-condition': 2,
105
+ 'no-control-regex': 2,
106
+ 'no-debugger': 2,
107
+ 'no-delete-var': 2,
108
+ 'no-dupe-args': 2,
109
+ 'no-dupe-class-members': 2,
110
+ 'no-dupe-else-if': 2,
111
+ 'no-dupe-keys': 2,
112
+ 'no-duplicate-case': 2,
113
+ 'no-empty': [2, { allowEmptyCatch: true }],
114
+ 'no-empty-character-class': 2,
115
+ 'no-empty-function': 'off',
116
+ 'no-empty-pattern': 2,
117
+ 'no-eval': 2,
118
+ 'no-ex-assign': 2,
119
+ 'no-extra-boolean-cast': 2,
120
+ 'no-extra-semi': 'off',
121
+ 'no-fallthrough': 2,
122
+ 'no-func-assign': 2,
123
+ 'no-global-assign': 2,
124
+ 'no-import-assign': 0, // used in some unit tests
125
+ 'no-inner-declarations': 2,
126
+ 'no-invalid-regexp': 2,
127
+ 'no-invalid-this': 0, // too many false positives in valid classes
128
+ 'no-irregular-whitespace': 2,
129
+ 'no-misleading-character-class': 2,
130
+ 'no-mixed-spaces-and-tabs': 2,
131
+ 'no-new-symbol': 2,
132
+ 'no-new-wrappers': 2,
133
+ 'no-obj-calls': 2,
134
+ 'no-octal': 2,
135
+ 'no-prototype-builtins': 2,
136
+ 'no-redeclare': 2,
137
+ 'no-regex-spaces': 2,
138
+ 'no-restricted-imports': [
139
+ 2,
140
+ 'rxjs/Rx',
141
+ 'rxjs/internals',
142
+ 'rxjs/Observable',
143
+ 'rxjs/Observer',
144
+ 'rxjs/Subject',
145
+ 'rxjs/observable/defer',
146
+ 'rxjs/observable/merge',
147
+ 'rxjs/observable/of',
148
+ 'rxjs/observable/timer',
149
+ 'rxjs/observable/combineLatest',
150
+ 'rxjs/add/observable/combineLatest',
151
+ 'rxjs/add/observable/of',
152
+ 'rxjs/add/observable/merge',
153
+ 'rxjs/add/operator/debounceTime',
154
+ 'rxjs/add/operator/distinctUntilChanged',
155
+ 'rxjs/add/operator/do',
156
+ 'rxjs/add/operator/filter',
157
+ 'rxjs/add/operator/map',
158
+ 'rxjs/add/operator/retry',
159
+ 'rxjs/add/operator/startWith',
160
+ 'rxjs/add/operator/switchMap',
161
+ 'rxjs/observable/interval',
162
+ 'rxjs/observable/forkJoin',
163
+ ],
164
+ 'no-self-assign': 2,
165
+ 'no-setter-return': 2,
166
+ 'no-shadow': 0, // it is buggy with TypeScript enums
167
+ 'no-shadow-restricted-names': 2,
168
+ 'no-sparse-arrays': 2,
169
+ 'no-this-before-super': 2,
170
+ 'no-throw-literal': 2,
171
+ 'no-undef': 2,
172
+ 'no-undef-init': 2,
173
+ 'no-underscore-dangle': 0,
174
+ 'no-unexpected-multiline': 0, // prettier
175
+ 'no-unreachable': 2,
176
+ 'no-unsafe-finally': 2,
177
+ 'no-unsafe-negation': 2,
178
+ 'no-unused-labels': 2,
179
+ 'no-unused-vars': 0, // replaced by `unused-imports/no-unused-vars`
180
+ 'no-useless-catch': 2,
181
+ 'no-useless-escape': 2,
182
+ 'no-unneeded-ternary': 2,
183
+ 'no-duplicate-imports': 0, // too many false-positives (with e.g import type + import on next line)
184
+ 'no-var': 2,
185
+ 'no-with': 2,
186
+ 'object-shorthand': 2,
187
+ 'one-var': [2, 'never'],
188
+ 'prefer-const': [
189
+ 2,
190
+ {
191
+ destructuring: 'all',
192
+ },
193
+ ],
194
+ 'require-yield': 2,
195
+ 'spaced-comment': [
196
+ 2,
197
+ 'always',
198
+ {
199
+ markers: ['/'],
200
+ },
201
+ ],
202
+ 'use-isnan': 2,
203
+ 'valid-typeof': 2,
204
+ 'no-await-in-loop': 2,
205
+ 'no-extend-native': 2,
206
+ 'guard-for-in': 2,
207
+ 'jest/expect-expect': 0,
208
+ 'jest/no-commented-out-tests': 0,
209
+ 'jest/no-export': 0, // conflicts with typescript isolatedModules
210
+ 'jest/no-conditional-expect': 0,
211
+ 'jest/no-disabled-tests': 0,
212
+ '@typescript-eslint/no-namespace': [
213
+ 2,
214
+ {
215
+ allowDeclarations: true, // allows `namespace NodeJS {}` augmentations
216
+ },
217
+ ],
218
+ '@typescript-eslint/no-unused-vars': [
219
+ 0, // replaced by `unused-imports/no-unused-vars`
220
+ {
221
+ varsIgnorePattern: '^_',
222
+ argsIgnorePattern: '^_',
223
+ },
224
+ ],
225
+ 'unused-imports/no-unused-imports': 2,
226
+ 'unused-imports/no-unused-vars': [
227
+ 2,
228
+ { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
229
+ ],
230
+ '@typescript-eslint/no-empty-function': 0,
231
+ '@typescript-eslint/no-var-requires': 0,
232
+ '@typescript-eslint/no-explicit-any': 0,
233
+ '@typescript-eslint/no-non-null-assertion': 0,
234
+ '@typescript-eslint/explicit-module-boundary-types': [
235
+ 2,
236
+ {
237
+ allowArgumentsExplicitlyTypedAsAny: true,
238
+ },
239
+ ],
240
+ '@typescript-eslint/array-type': 2,
241
+ '@typescript-eslint/prefer-regexp-exec': 0, // auto-fixer breaks code sometimes!
242
+ 'arrow-parens': [2, 'as-needed'],
243
+ 'arrow-body-style': 0,
244
+ 'unicorn/no-array-callback-reference': 0, // false positives
245
+ 'unicorn/no-process-exit': 0,
246
+ 'unicorn/no-array-push-push': 0,
247
+ 'unicorn/no-abusive-eslint-disable': 0,
248
+ 'unicorn/number-literal-case': 0, // conflicts with prettier
249
+ 'unicorn/prevent-abbreviations': 0,
250
+ 'unicorn/prefer-module': 0,
251
+ 'unicorn/no-null': 0,
252
+ 'unicorn/filename-case': 0,
253
+ 'unicorn/prefer-node-protocol': 0,
254
+ 'unicorn/prefer-set-has': 0,
255
+ 'unicorn/explicit-length-check': 0,
256
+ 'unicorn/no-array-for-each': 0,
257
+ 'unicorn/import-style': 0, // todo: fix
258
+ 'unicorn/prefer-spread': 0, // fails on joiSchema.concat() which is not an array!
259
+ 'unicorn/better-regex': 0, // we still believe that [0-9] is clearer than [\d]
260
+ 'unicorn/no-object-as-default-parameter': 0, // doesn't allow e.g method (opt = { skipValidation: true })
261
+ 'unicorn/catch-error-name': [
262
+ 2,
263
+ {
264
+ name: 'err',
265
+ ignore: [/^err\d*$/, /^_/],
266
+ },
267
+ ],
268
+ 'unicorn/prefer-switch': 0,
269
+ 'unicorn/no-useless-undefined': 0,
270
+ 'unicorn/prefer-ternary': [0, 'only-single-line'], // single-line doesn't really work, hence disabled
271
+ 'unicorn/numeric-separators-style': [2, { onlyIfContainsSeparator: true }],
272
+ 'unicorn/consistent-destructuring': 0, // todo: enable later
273
+ 'unicorn/no-nested-ternary': 0,
274
+ 'unicorn/consistent-function-scoping': 0, // todo: consider enabling later
275
+ 'unicorn/no-this-assignment': 0,
276
+ 'unicorn/prefer-string-slice': 0,
277
+ 'unicorn/prefer-number-properties': 0,
278
+ 'unicorn/prefer-negative-index': 0,
279
+ 'unicorn/prefer-regexp-test': 0,
280
+ 'unicorn/prefer-query-selector': 0,
281
+ 'unicorn/prefer-prototype-methods': 0, // false-positive on node promisify() of callback functions
282
+ '@typescript-eslint/return-await': [2, 'always'],
283
+ '@typescript-eslint/require-await': 0,
284
+ '@typescript-eslint/no-misused-promises': 0,
285
+ '@typescript-eslint/no-unsafe-assignment': 0,
286
+ '@typescript-eslint/no-unsafe-member-access': 0,
287
+ '@typescript-eslint/no-unsafe-call': 0,
288
+ '@typescript-eslint/restrict-template-expressions': 0,
289
+ '@typescript-eslint/no-unsafe-return': 0,
290
+ '@typescript-eslint/restrict-plus-operands': 0,
291
+ '@typescript-eslint/unbound-method': 0,
292
+ },
293
+ }
@@ -15,321 +15,59 @@ module.exports = {
15
15
  // testcafe
16
16
  fixture: 'readable',
17
17
  },
18
- extends: [
19
- 'eslint:recommended',
20
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.ts
21
- 'plugin:@typescript-eslint/recommended',
22
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
23
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
24
- // 'plugin:jest/recommended', // add manually if needed!
25
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/configs/recommended.js
26
- 'plugin:unicorn/recommended',
27
- 'prettier', // must be last! it only turns off eslint rules that conflict with prettier
28
- ],
29
18
  ignorePatterns: ['**/__exclude/**'],
30
- parser: '@typescript-eslint/parser',
31
- parserOptions: {
32
- project: 'tsconfig.json',
33
- sourceType: 'module',
34
- ecmaVersion: 2020,
35
- },
36
- plugins: [
37
- 'jsdoc',
38
- 'import',
39
- '@typescript-eslint',
40
- 'unused-imports',
41
- // 'jest', // add manually if needed!
42
- 'unicorn',
43
- ],
44
- rules: {
45
- '@typescript-eslint/adjacent-overload-signatures': 2,
46
- '@typescript-eslint/ban-ts-comment': 0,
47
- '@typescript-eslint/ban-types': [
48
- 2,
49
- {
50
- types: {
51
- Object: {
52
- message: 'Avoid using the `Object` type. Did you mean `object`?',
53
- },
54
- Boolean: {
55
- message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
56
- },
57
- Number: {
58
- message: 'Avoid using the `Number` type. Did you mean `number`?',
59
- },
60
- String: {
61
- message: 'Avoid using the `String` type. Did you mean `string`?',
62
- },
63
- Symbol: {
64
- message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
65
- },
66
- },
67
- },
68
- ],
69
- '@typescript-eslint/consistent-type-assertions': 2,
70
- '@typescript-eslint/consistent-type-definitions': 2,
71
- '@typescript-eslint/naming-convention': [
72
- 0,
73
- {
74
- // todo: clarify later, currently disabled
75
- selector: 'default',
76
- format: ['camelCase', 'UPPER_CASE'],
77
- },
78
- ],
79
- '@typescript-eslint/no-array-constructor': 2,
80
- '@typescript-eslint/no-empty-interface': 0, // too inconvenient
81
- '@typescript-eslint/no-extra-non-null-assertion': 2,
82
- '@typescript-eslint/no-extra-semi': 0, // prettier handles it
83
- '@typescript-eslint/no-floating-promises': 2,
84
- '@typescript-eslint/no-inferrable-types': [
85
- 2,
86
- {
87
- ignoreParameters: true,
88
- },
89
- ],
90
- '@typescript-eslint/no-misused-new': 2,
91
- '@typescript-eslint/no-non-null-asserted-optional-chain': 2,
92
- '@typescript-eslint/no-this-alias': 0, // buggy
93
- '@typescript-eslint/no-unused-expressions': 2,
94
- '@typescript-eslint/prefer-as-const': 2,
95
- '@typescript-eslint/prefer-for-of': 2,
96
- '@typescript-eslint/prefer-function-type': 2,
97
- '@typescript-eslint/prefer-namespace-keyword': 2,
98
- '@typescript-eslint/promise-function-async': [
99
- 2,
100
- {
101
- checkArrowFunctions: false,
102
- checkFunctionDeclarations: true,
103
- checkFunctionExpressions: true,
104
- checkMethodDeclarations: true,
105
- },
106
- ],
107
- '@typescript-eslint/triple-slash-reference': 2,
108
- complexity: [
109
- 2,
110
- {
111
- max: 30,
19
+ overrides: [
20
+ {
21
+ files: ['*.ts', '*.tsx'],
22
+ extends: [
23
+ 'eslint:recommended',
24
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.ts
25
+ 'plugin:@typescript-eslint/recommended',
26
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
27
+ 'plugin:@typescript-eslint/recommended-requiring-type-checking',
28
+ // 'plugin:jest/recommended', // add manually if needed!
29
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/configs/recommended.js
30
+ 'plugin:unicorn/recommended',
31
+ './eslint-rules.js',
32
+ 'prettier', // must be last! it only turns off eslint rules that conflict with prettier
33
+ ],
34
+ parser: '@typescript-eslint/parser',
35
+ parserOptions: {
36
+ // project: ['tsconfig.eslint.json', 'scripts/tsconfig.json', 'e2e/tsconfig.json', 'tsconfig.json'],
37
+ project: ['tsconfig.json'],
38
+ sourceType: 'module',
39
+ ecmaVersion: 2020,
112
40
  },
113
- ],
114
- 'constructor-super': 2,
115
- curly: [2, 'multi-line'],
116
- 'eol-last': 2,
117
- eqeqeq: [2, 'smart'],
118
- 'for-direction': 2,
119
- 'getter-return': 2,
120
- 'id-blacklist': [
121
- 2,
122
- 'any',
123
- 'Number',
124
- 'number',
125
- 'String',
126
- 'string',
127
- 'Boolean',
128
- 'boolean',
129
- 'Undefined',
130
- 'undefined',
131
- ],
132
- 'id-match': 2,
133
- // "import/order": "error",
134
- 'jsdoc/check-alignment': 2,
135
- // "jsdoc/check-indentation": "error",
136
- 'jsdoc/newline-after-description': 2,
137
- 'no-array-constructor': 'off',
138
- 'no-async-promise-executor': 2,
139
- 'no-bitwise': 2,
140
- 'no-caller': 2,
141
- 'no-case-declarations': 2,
142
- 'no-class-assign': 2,
143
- 'no-compare-neg-zero': 2,
144
- 'no-cond-assign': 2,
145
- 'no-const-assign': 2,
146
- 'no-constant-condition': 2,
147
- 'no-control-regex': 2,
148
- 'no-debugger': 2,
149
- 'no-delete-var': 2,
150
- 'no-dupe-args': 2,
151
- 'no-dupe-class-members': 2,
152
- 'no-dupe-else-if': 2,
153
- 'no-dupe-keys': 2,
154
- 'no-duplicate-case': 2,
155
- 'no-empty': [2, { allowEmptyCatch: true }],
156
- 'no-empty-character-class': 2,
157
- 'no-empty-function': 'off',
158
- 'no-empty-pattern': 2,
159
- 'no-eval': 2,
160
- 'no-ex-assign': 2,
161
- 'no-extra-boolean-cast': 2,
162
- 'no-extra-semi': 'off',
163
- 'no-fallthrough': 2,
164
- 'no-func-assign': 2,
165
- 'no-global-assign': 2,
166
- 'no-import-assign': 0, // used in some unit tests
167
- 'no-inner-declarations': 2,
168
- 'no-invalid-regexp': 2,
169
- 'no-invalid-this': 0, // too many false positives in valid classes
170
- 'no-irregular-whitespace': 2,
171
- 'no-misleading-character-class': 2,
172
- 'no-mixed-spaces-and-tabs': 2,
173
- 'no-new-symbol': 2,
174
- 'no-new-wrappers': 2,
175
- 'no-obj-calls': 2,
176
- 'no-octal': 2,
177
- 'no-prototype-builtins': 2,
178
- 'no-redeclare': 2,
179
- 'no-regex-spaces': 2,
180
- 'no-restricted-imports': [
181
- 2,
182
- 'rxjs/Rx',
183
- 'rxjs/internals',
184
- 'rxjs/Observable',
185
- 'rxjs/Observer',
186
- 'rxjs/Subject',
187
- 'rxjs/observable/defer',
188
- 'rxjs/observable/merge',
189
- 'rxjs/observable/of',
190
- 'rxjs/observable/timer',
191
- 'rxjs/observable/combineLatest',
192
- 'rxjs/add/observable/combineLatest',
193
- 'rxjs/add/observable/of',
194
- 'rxjs/add/observable/merge',
195
- 'rxjs/add/operator/debounceTime',
196
- 'rxjs/add/operator/distinctUntilChanged',
197
- 'rxjs/add/operator/do',
198
- 'rxjs/add/operator/filter',
199
- 'rxjs/add/operator/map',
200
- 'rxjs/add/operator/retry',
201
- 'rxjs/add/operator/startWith',
202
- 'rxjs/add/operator/switchMap',
203
- 'rxjs/observable/interval',
204
- 'rxjs/observable/forkJoin',
205
- ],
206
- 'no-self-assign': 2,
207
- 'no-setter-return': 2,
208
- 'no-shadow': 0, // it is buggy with TypeScript enums
209
- 'no-shadow-restricted-names': 2,
210
- 'no-sparse-arrays': 2,
211
- 'no-this-before-super': 2,
212
- 'no-throw-literal': 2,
213
- 'no-undef': 2,
214
- 'no-undef-init': 2,
215
- 'no-underscore-dangle': 0,
216
- 'no-unexpected-multiline': 0, // prettier
217
- 'no-unreachable': 2,
218
- 'no-unsafe-finally': 2,
219
- 'no-unsafe-negation': 2,
220
- 'no-unused-labels': 2,
221
- 'no-unused-vars': 0, // replaced by `unused-imports/no-unused-vars`
222
- 'no-useless-catch': 2,
223
- 'no-useless-escape': 2,
224
- 'no-unneeded-ternary': 2,
225
- 'no-duplicate-imports': 0, // too many false-positives (with e.g import type + import on next line)
226
- 'no-var': 2,
227
- 'no-with': 2,
228
- 'object-shorthand': 2,
229
- 'one-var': [2, 'never'],
230
- 'prefer-const': [
231
- 2,
232
- {
233
- destructuring: 'all',
41
+ plugins: [
42
+ 'jsdoc',
43
+ 'import',
44
+ '@typescript-eslint',
45
+ 'unused-imports',
46
+ // 'jest', // add manually if needed!
47
+ 'unicorn',
48
+ ],
49
+ },
50
+ {
51
+ files: ['*.vue'],
52
+ extends: [
53
+ 'eslint:recommended',
54
+ 'plugin:@typescript-eslint/recommended',
55
+ 'plugin:@typescript-eslint/recommended-requiring-type-checking',
56
+ 'plugin:unicorn/recommended',
57
+ './eslint-rules.js',
58
+ 'plugin:vue/recommended',
59
+ 'prettier', // must go last
60
+ ],
61
+ env: {
62
+ browser: true,
234
63
  },
235
- ],
236
- 'require-yield': 2,
237
- 'spaced-comment': [
238
- 2,
239
- 'always',
240
- {
241
- markers: ['/'],
64
+ parser: 'vue-eslint-parser',
65
+ parserOptions: {
66
+ parser: '@typescript-eslint/parser',
67
+ extraFileExtensions: ['.vue'],
68
+ project: ['tsconfig.json'],
69
+ createDefaultProgram: true,
242
70
  },
243
- ],
244
- 'use-isnan': 2,
245
- 'valid-typeof': 2,
246
- 'no-await-in-loop': 2,
247
- 'no-extend-native': 2,
248
- 'guard-for-in': 2,
249
- 'jest/expect-expect': 0,
250
- 'jest/no-commented-out-tests': 0,
251
- 'jest/no-export': 0, // conflicts with typescript isolatedModules
252
- 'jest/no-conditional-expect': 0,
253
- 'jest/no-disabled-tests': 0,
254
- '@typescript-eslint/no-namespace': [
255
- 2,
256
- {
257
- allowDeclarations: true, // allows `namespace NodeJS {}` augmentations
258
- },
259
- ],
260
- '@typescript-eslint/no-unused-vars': [
261
- 0, // replaced by `unused-imports/no-unused-vars`
262
- {
263
- varsIgnorePattern: '^_',
264
- argsIgnorePattern: '^_',
265
- },
266
- ],
267
- 'unused-imports/no-unused-imports': 2,
268
- 'unused-imports/no-unused-vars': [
269
- 2,
270
- { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
271
- ],
272
- '@typescript-eslint/no-empty-function': 0,
273
- '@typescript-eslint/no-var-requires': 0,
274
- '@typescript-eslint/no-explicit-any': 0,
275
- '@typescript-eslint/no-non-null-assertion': 0,
276
- '@typescript-eslint/explicit-module-boundary-types': [
277
- 2,
278
- {
279
- allowArgumentsExplicitlyTypedAsAny: true,
280
- },
281
- ],
282
- '@typescript-eslint/array-type': 2,
283
- '@typescript-eslint/prefer-regexp-exec': 0, // auto-fixer breaks code sometimes!
284
- 'arrow-parens': [2, 'as-needed'],
285
- 'arrow-body-style': 0,
286
- 'unicorn/no-array-callback-reference': 0, // false positives
287
- 'unicorn/no-process-exit': 0,
288
- 'unicorn/no-array-push-push': 0,
289
- 'unicorn/no-abusive-eslint-disable': 0,
290
- 'unicorn/number-literal-case': 0, // conflicts with prettier
291
- 'unicorn/prevent-abbreviations': 0,
292
- 'unicorn/prefer-module': 0,
293
- 'unicorn/no-null': 0,
294
- 'unicorn/filename-case': 0,
295
- 'unicorn/prefer-node-protocol': 0,
296
- 'unicorn/prefer-set-has': 0,
297
- 'unicorn/explicit-length-check': 0,
298
- 'unicorn/no-array-for-each': 0,
299
- 'unicorn/import-style': 0, // todo: fix
300
- 'unicorn/prefer-spread': 0, // fails on joiSchema.concat() which is not an array!
301
- 'unicorn/better-regex': 0, // we still believe that [0-9] is clearer than [\d]
302
- 'unicorn/no-object-as-default-parameter': 0, // doesn't allow e.g method (opt = { skipValidation: true })
303
- 'unicorn/catch-error-name': [
304
- 2,
305
- {
306
- name: 'err',
307
- ignore: [/^err\d*$/, /^_/],
308
- },
309
- ],
310
- 'unicorn/prefer-switch': 0,
311
- 'unicorn/no-useless-undefined': 0,
312
- 'unicorn/prefer-ternary': [0, 'only-single-line'], // single-line doesn't really work, hence disabled
313
- 'unicorn/numeric-separators-style': [2, { onlyIfContainsSeparator: true }],
314
- 'unicorn/consistent-destructuring': 0, // todo: enable later
315
- 'unicorn/no-nested-ternary': 0,
316
- 'unicorn/consistent-function-scoping': 0, // todo: consider enabling later
317
- 'unicorn/no-this-assignment': 0,
318
- 'unicorn/prefer-string-slice': 0,
319
- 'unicorn/prefer-number-properties': 0,
320
- 'unicorn/prefer-negative-index': 0,
321
- 'unicorn/prefer-regexp-test': 0,
322
- 'unicorn/prefer-query-selector': 0,
323
- 'unicorn/prefer-prototype-methods': 0, // false-positive on node promisify() of callback functions
324
- '@typescript-eslint/return-await': [2, 'always'],
325
- '@typescript-eslint/require-await': 0,
326
- '@typescript-eslint/no-misused-promises': 0,
327
- '@typescript-eslint/no-unsafe-assignment': 0,
328
- '@typescript-eslint/no-unsafe-member-access': 0,
329
- '@typescript-eslint/no-unsafe-call': 0,
330
- '@typescript-eslint/restrict-template-expressions': 0,
331
- '@typescript-eslint/no-unsafe-return': 0,
332
- '@typescript-eslint/restrict-plus-operands': 0,
333
- '@typescript-eslint/unbound-method': 0,
334
- },
71
+ },
72
+ ],
335
73
  }
@@ -24,7 +24,8 @@ const stylelintConfigPath =
24
24
  [`stylelint.config.js`].find(fs.existsSync) || `${cfgDir}/stylelint.config.js`
25
25
 
26
26
  // this is to support "Solution style tsconfig.json" (as used in Angular10, for example)
27
- const tsconfigPathRoot = ['tsconfig.base.json'].find(p => fs.existsSync(p)) || 'tsconfig.json'
27
+ // const tsconfigPathRoot = ['tsconfig.base.json'].find(p => fs.existsSync(p)) || 'tsconfig.json'
28
+ const tsconfigPathRoot = 'tsconfig.json'
28
29
 
29
30
  const eslintConfigPathRoot =
30
31
  ['.eslintrc.js'].find(p => fs.existsSync(p)) || `${cfgDir}/eslint.config.js`
@@ -41,13 +42,13 @@ const linters = {
41
42
  const files = micromatch.not(match, lintExclude)
42
43
  if (!files) return []
43
44
  const filesList = files.join(' ')
44
- const filesListNoVue = micromatch.not(files, ['**/*.vue']).join(' ')
45
+ const filesListTSLint = micromatch(files, ['**/*.{ts,tsx}']).join(' ')
45
46
  return [
46
- `${eslintCmd} --config ${eslintConfigPathRoot} --parser-options=project:./${tsconfigPathRoot} ${filesList}`,
47
- `${tslintCmd} ${filesListNoVue}`,
48
- `${tslintCmd} -p ${tsconfigPathRoot} ${filesListNoVue}`,
47
+ `${eslintCmd} --config ${eslintConfigPathRoot} ${filesList}`,
48
+ filesListTSLint && `${tslintCmd} ${filesListTSLint}`,
49
+ filesListTSLint && `${tslintCmd} -p ${tsconfigPathRoot} ${filesListTSLint}`,
49
50
  `${prettierCmd} ${filesList}`,
50
- ]
51
+ ].filter(Boolean)
51
52
  },
52
53
 
53
54
  // For all other files we run only Prettier (because e.g TSLint screws *.scss files)
@@ -2,22 +2,31 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.eslintAllCommand = void 0;
4
4
  const fs = require("fs");
5
+ const yargs = require("yargs");
5
6
  const paths_cnst_1 = require("../cnst/paths.cnst");
6
7
  const tslint_util_1 = require("../util/tslint.util");
7
8
  /**
8
9
  * Runs `eslint` command for all predefined paths (e.g /src, /scripts, etc).
9
10
  */
10
11
  async function eslintAllCommand() {
12
+ const { ext } = yargs.options({
13
+ ext: {
14
+ type: 'string',
15
+ default: 'ts,tsx,vue',
16
+ },
17
+ }).argv;
18
+ const extensions = ext.split(',');
11
19
  const eslintConfigPathRoot = ['./.eslintrc.js'].find(p => fs.existsSync(p)) || `${paths_cnst_1.cfgDir}/eslint.config.js`;
12
20
  const eslintConfigPathScripts = ['./scripts/.eslintrc.js', './.eslintrc.js'].find(p => fs.existsSync(p)) ||
13
21
  `${paths_cnst_1.cfgDir}/eslint.config.js`;
14
22
  const eslintConfigPathE2e = ['./e2e/.eslintrc.js', './.eslintrc.js'].find(p => fs.existsSync(p)) ||
15
23
  `${paths_cnst_1.cfgDir}/eslint.config.js`;
16
- const tsconfigPath = (0, tslint_util_1.getTSConfigPath)();
24
+ // const tsconfigPath = getTSConfigPath()
17
25
  const tsconfigPathScripts = (0, tslint_util_1.getTSConfigPathScripts)();
18
26
  const tsconfigPathE2e = `./e2e/tsconfig.json`;
19
27
  // /src
20
- await (0, tslint_util_1.runESLint)(`./src`, eslintConfigPathRoot, tsconfigPath);
28
+ // await runESLint(`./src`, eslintConfigPathRoot, tsconfigPath, extensions)
29
+ await (0, tslint_util_1.runESLint)(`./src`, eslintConfigPathRoot, undefined, extensions);
21
30
  // /scripts
22
31
  await (0, tslint_util_1.runESLint)(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts);
23
32
  // /e2e
@@ -2,4 +2,4 @@ export declare function runTSLint(dir: string, excludePaths: string[] | undefine
2
2
  export declare function getTSLintConfigPath(): string;
3
3
  export declare function getTSConfigPath(): string;
4
4
  export declare function getTSConfigPathScripts(): string;
5
- export declare function runESLint(dir: string, eslintConfigPath: string, tsconfigPath?: string): Promise<void>;
5
+ export declare function runESLint(dir: string, eslintConfigPath: string, tsconfigPath: string | undefined, extensions?: string[]): Promise<void>;
@@ -29,20 +29,21 @@ function getTSLintConfigPath() {
29
29
  exports.getTSLintConfigPath = getTSLintConfigPath;
30
30
  function getTSConfigPath() {
31
31
  // this is to support "Solution style tsconfig.json" (as used in Angular10, for example)
32
- return [`./tsconfig.base.json`].find(p => fs.existsSync(p)) || `./tsconfig.json`;
32
+ // return [`./tsconfig.base.json`].find(p => fs.existsSync(p)) || `./tsconfig.json`
33
+ return './tsconfig.json';
33
34
  }
34
35
  exports.getTSConfigPath = getTSConfigPath;
35
36
  function getTSConfigPathScripts() {
36
37
  return [`./scripts/tsconfig.json`].find(p => fs.existsSync(p)) || `${paths_cnst_1.scriptsDir}/tsconfig.json`;
37
38
  }
38
39
  exports.getTSConfigPathScripts = getTSConfigPathScripts;
39
- async function runESLint(dir, eslintConfigPath, tsconfigPath) {
40
+ async function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue']) {
40
41
  if (!fs.existsSync(dir))
41
42
  return; // faster to bail-out like this
42
43
  const args = [
43
44
  `--config`,
44
45
  eslintConfigPath,
45
- `${dir}/**/*.{ts,tsx,vue}`,
46
+ `${dir}/**/*.{${extensions.join(',')}}`,
46
47
  ...(tsconfigPath ? [`--parser-options=project:${tsconfigPath}`] : []),
47
48
  `--no-error-on-unmatched-pattern`,
48
49
  `--fix`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "12.3.2",
3
+ "version": "12.4.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",
@@ -1,19 +0,0 @@
1
- /**
2
- * @naturalcycles/dev-lib/cfg/eslint-vue.config.js
3
- */
4
- module.exports = {
5
- extends: [
6
- './eslint.config.js',
7
- 'plugin:vue/recommended',
8
- 'prettier', // must go last
9
- ],
10
- env: {
11
- browser: true,
12
- },
13
- parser: 'vue-eslint-parser',
14
- parserOptions: {
15
- parser: '@typescript-eslint/parser',
16
- extraFileExtensions: ['.vue'],
17
- },
18
- rules: {},
19
- }