@typescript-eslint/eslint-plugin 6.0.0-alpha.98 → 6.0.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/README.md +2 -0
- package/dist/configs/all.js +2 -0
- package/dist/configs/all.js.map +1 -1
- package/dist/configs/disable-type-checked.js +3 -0
- package/dist/configs/disable-type-checked.js.map +1 -1
- package/dist/configs/recommended-type-checked.js +6 -0
- package/dist/configs/recommended-type-checked.js.map +1 -1
- package/dist/configs/recommended.js +2 -0
- package/dist/configs/recommended.js.map +1 -1
- package/dist/configs/strict-type-checked.js +4 -0
- package/dist/configs/strict-type-checked.js.map +1 -1
- package/dist/configs/stylistic-type-checked.js +0 -1
- package/dist/configs/stylistic-type-checked.js.map +1 -1
- package/dist/configs/stylistic.js +0 -2
- package/dist/configs/stylistic.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/rules/array-type.js +19 -20
- package/dist/rules/array-type.js.map +1 -1
- package/dist/rules/ban-ts-comment.js +33 -35
- package/dist/rules/ban-ts-comment.js.map +1 -1
- package/dist/rules/ban-types.js +75 -14
- package/dist/rules/ban-types.js.map +1 -1
- package/dist/rules/class-literal-property-style.js +38 -21
- package/dist/rules/class-literal-property-style.js.map +1 -1
- package/dist/rules/comma-dangle.js +4 -2
- package/dist/rules/comma-dangle.js.map +1 -1
- package/dist/rules/comma-spacing.js +5 -0
- package/dist/rules/comma-spacing.js.map +1 -1
- package/dist/rules/consistent-generic-constructors.js +1 -0
- package/dist/rules/consistent-generic-constructors.js.map +1 -1
- package/dist/rules/consistent-indexed-object-style.js +1 -0
- package/dist/rules/consistent-indexed-object-style.js.map +1 -1
- package/dist/rules/consistent-type-assertions.js +49 -0
- package/dist/rules/consistent-type-assertions.js.map +1 -1
- package/dist/rules/consistent-type-definitions.js +1 -0
- package/dist/rules/consistent-type-definitions.js.map +1 -1
- package/dist/rules/consistent-type-exports.js +1 -0
- package/dist/rules/consistent-type-exports.js.map +1 -1
- package/dist/rules/consistent-type-imports.js +2 -0
- package/dist/rules/consistent-type-imports.js.map +1 -1
- package/dist/rules/enum-utils/shared.js +61 -0
- package/dist/rules/enum-utils/shared.js.map +1 -0
- package/dist/rules/explicit-function-return-type.js.map +1 -1
- package/dist/rules/explicit-member-accessibility.js +43 -44
- package/dist/rules/explicit-member-accessibility.js.map +1 -1
- package/dist/rules/explicit-module-boundary-types.js +1 -1
- package/dist/rules/explicit-module-boundary-types.js.map +1 -1
- package/dist/rules/func-call-spacing.js +2 -0
- package/dist/rules/func-call-spacing.js.map +1 -1
- package/dist/rules/indent.js.map +1 -1
- package/dist/rules/index.js +4 -0
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/key-spacing.js.map +1 -1
- package/dist/rules/keyword-spacing.js.map +1 -1
- package/dist/rules/lines-around-comment.js +78 -81
- package/dist/rules/lines-around-comment.js.map +1 -1
- package/dist/rules/lines-between-class-members.js +7 -5
- package/dist/rules/lines-between-class-members.js.map +1 -1
- package/dist/rules/member-delimiter-style.js +45 -27
- package/dist/rules/member-delimiter-style.js.map +1 -1
- package/dist/rules/member-ordering.js +55 -66
- package/dist/rules/member-ordering.js.map +1 -1
- package/dist/rules/method-signature-style.js +1 -0
- package/dist/rules/method-signature-style.js.map +1 -1
- package/dist/rules/naming-convention-utils/enums.js +6 -12
- package/dist/rules/naming-convention-utils/enums.js.map +1 -1
- package/dist/rules/naming-convention-utils/schema.js +50 -25
- package/dist/rules/naming-convention-utils/schema.js.map +1 -1
- package/dist/rules/naming-convention.js.map +1 -1
- package/dist/rules/no-base-to-string.js +2 -2
- package/dist/rules/no-base-to-string.js.map +1 -1
- package/dist/rules/no-confusing-void-expression.js +1 -0
- package/dist/rules/no-confusing-void-expression.js.map +1 -1
- package/dist/rules/no-duplicate-type-constituents.js +161 -0
- package/dist/rules/no-duplicate-type-constituents.js.map +1 -0
- package/dist/rules/no-empty-function.js +1 -0
- package/dist/rules/no-empty-function.js.map +1 -1
- package/dist/rules/no-empty-interface.js +2 -1
- package/dist/rules/no-empty-interface.js.map +1 -1
- package/dist/rules/no-explicit-any.js +1 -1
- package/dist/rules/no-explicit-any.js.map +1 -1
- package/dist/rules/no-extraneous-class.js +2 -3
- package/dist/rules/no-extraneous-class.js.map +1 -1
- package/dist/rules/no-implied-eval.js +1 -0
- package/dist/rules/no-implied-eval.js.map +1 -1
- package/dist/rules/no-inferrable-types.js.map +1 -1
- package/dist/rules/no-invalid-void-type.js +1 -1
- package/dist/rules/no-invalid-void-type.js.map +1 -1
- package/dist/rules/no-loop-func.js.map +1 -1
- package/dist/rules/no-magic-numbers.js.map +1 -1
- package/dist/rules/no-misused-promises.js +3 -2
- package/dist/rules/no-misused-promises.js.map +1 -1
- package/dist/rules/no-redeclare.js +2 -1
- package/dist/rules/no-redeclare.js.map +1 -1
- package/dist/rules/no-redundant-type-constituents.js +2 -0
- package/dist/rules/no-redundant-type-constituents.js.map +1 -1
- package/dist/rules/no-restricted-imports.js +80 -21
- package/dist/rules/no-restricted-imports.js.map +1 -1
- package/dist/rules/no-shadow.js +2 -1
- package/dist/rules/no-shadow.js.map +1 -1
- package/dist/rules/no-type-alias.js +24 -15
- package/dist/rules/no-type-alias.js.map +1 -1
- package/dist/rules/no-unnecessary-condition.js +2 -2
- package/dist/rules/no-unnecessary-condition.js.map +1 -1
- package/dist/rules/no-unnecessary-qualifier.js.map +1 -1
- package/dist/rules/no-unnecessary-type-assertion.js +1 -0
- package/dist/rules/no-unnecessary-type-assertion.js.map +1 -1
- package/dist/rules/no-unsafe-argument.js +3 -3
- package/dist/rules/no-unsafe-argument.js.map +1 -1
- package/dist/rules/no-unsafe-declaration-merging.js +1 -1
- package/dist/rules/no-unsafe-declaration-merging.js.map +1 -1
- package/dist/rules/no-unsafe-enum-comparison.js +119 -0
- package/dist/rules/no-unsafe-enum-comparison.js.map +1 -0
- package/dist/rules/no-unused-vars.js +4 -0
- package/dist/rules/no-unused-vars.js.map +1 -1
- package/dist/rules/no-use-before-define.js +1 -0
- package/dist/rules/no-use-before-define.js.map +1 -1
- package/dist/rules/padding-line-between-statements.js +11 -3
- package/dist/rules/padding-line-between-statements.js.map +1 -1
- package/dist/rules/parameter-properties.js +29 -30
- package/dist/rules/parameter-properties.js.map +1 -1
- package/dist/rules/prefer-includes.js +21 -5
- package/dist/rules/prefer-includes.js.map +1 -1
- package/dist/rules/prefer-nullish-coalescing.js +82 -63
- package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
- package/dist/rules/prefer-optional-chain-utils/PreferOptionalChainOptions.js +3 -0
- package/dist/rules/prefer-optional-chain-utils/PreferOptionalChainOptions.js.map +1 -0
- package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +419 -0
- package/dist/rules/prefer-optional-chain-utils/analyzeChain.js.map +1 -0
- package/dist/rules/prefer-optional-chain-utils/compareNodes.js +318 -0
- package/dist/rules/prefer-optional-chain-utils/compareNodes.js.map +1 -0
- package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +281 -0
- package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js.map +1 -0
- package/dist/rules/prefer-optional-chain.js +80 -391
- package/dist/rules/prefer-optional-chain.js.map +1 -1
- package/dist/rules/prefer-readonly.js +1 -1
- package/dist/rules/prefer-readonly.js.map +1 -1
- package/dist/rules/prefer-regexp-exec.js +7 -1
- package/dist/rules/prefer-regexp-exec.js.map +1 -1
- package/dist/rules/require-array-sort-compare.js +3 -2
- package/dist/rules/require-array-sort-compare.js.map +1 -1
- package/dist/rules/restrict-plus-operands.js +132 -96
- package/dist/rules/restrict-plus-operands.js.map +1 -1
- package/dist/rules/restrict-template-expressions.js +11 -6
- package/dist/rules/restrict-template-expressions.js.map +1 -1
- package/dist/rules/return-await.js +1 -0
- package/dist/rules/return-await.js.map +1 -1
- package/dist/rules/sort-type-constituents.js +1 -1
- package/dist/rules/sort-type-constituents.js.map +1 -1
- package/dist/rules/space-before-function-paren.js +4 -0
- package/dist/rules/space-before-function-paren.js.map +1 -1
- package/dist/rules/strict-boolean-expressions.js +7 -2
- package/dist/rules/strict-boolean-expressions.js.map +1 -1
- package/dist/rules/switch-exhaustiveness-check.js.map +1 -1
- package/dist/rules/triple-slash-reference.js +3 -0
- package/dist/rules/triple-slash-reference.js.map +1 -1
- package/dist/rules/type-annotation-spacing.js +16 -14
- package/dist/rules/type-annotation-spacing.js.map +1 -1
- package/dist/rules/typedef.js +1 -0
- package/dist/rules/typedef.js.map +1 -1
- package/dist/rules/unbound-method.js +1 -0
- package/dist/rules/unbound-method.js.map +1 -1
- package/dist/rules/unified-signatures.js +3 -3
- package/dist/rules/unified-signatures.js.map +1 -1
- package/dist/util/astUtils.js.map +1 -1
- package/dist/util/collectUnusedVariables.js +1 -1
- package/dist/util/collectUnusedVariables.js.map +1 -1
- package/dist/util/getOperatorPrecedence.js +112 -2
- package/dist/util/getOperatorPrecedence.js.map +1 -1
- package/dist/util/getStringLength.js +2 -2
- package/dist/util/getStringLength.js.map +1 -1
- package/dist/util/misc.js +1 -2
- package/dist/util/misc.js.map +1 -1
- package/docs/rules/README.md +2 -2
- package/docs/rules/ban-types.md +10 -0
- package/docs/rules/comma-dangle.md +1 -1
- package/docs/rules/explicit-module-boundary-types.md +1 -1
- package/docs/rules/lines-around-comment.md +3 -13
- package/docs/rules/naming-convention.md +63 -63
- package/docs/rules/no-duplicate-type-constituents.md +61 -0
- package/docs/rules/no-unnecessary-boolean-literal-compare.md +10 -10
- package/docs/rules/no-unnecessary-type-constraint.md +6 -2
- package/docs/rules/no-unsafe-enum-comparison.md +77 -0
- package/docs/rules/prefer-includes.md +1 -1
- package/docs/rules/prefer-nullish-coalescing.md +23 -0
- package/docs/rules/prefer-optional-chain.md +195 -4
- package/docs/rules/require-await.md +0 -2
- package/docs/rules/restrict-plus-operands.md +135 -25
- package/docs/rules/restrict-template-expressions.md +15 -3
- package/docs/rules/sort-type-constituents.md +3 -3
- package/docs/rules/triple-slash-reference.md +0 -2
- package/docs/rules/type-annotation-spacing.md +22 -8
- package/docs/rules/unified-signatures.md +0 -2
- package/package.json +22 -15
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBinaryOperatorPrecedence = exports.getOperatorPrecedence = exports.OperatorPrecedence = void 0;
|
|
3
|
+
exports.getBinaryOperatorPrecedence = exports.getOperatorPrecedence = exports.getOperatorPrecedenceForNode = exports.OperatorPrecedence = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
5
|
const typescript_1 = require("typescript");
|
|
5
6
|
var OperatorPrecedence;
|
|
6
7
|
(function (OperatorPrecedence) {
|
|
@@ -170,9 +171,92 @@ var OperatorPrecedence;
|
|
|
170
171
|
// -1 is lower than all other precedences. Returning it will cause binary expression
|
|
171
172
|
// parsing to stop.
|
|
172
173
|
OperatorPrecedence[OperatorPrecedence["Invalid"] = -1] = "Invalid";
|
|
173
|
-
})(OperatorPrecedence
|
|
174
|
+
})(OperatorPrecedence || (exports.OperatorPrecedence = OperatorPrecedence = {}));
|
|
175
|
+
function getOperatorPrecedenceForNode(node) {
|
|
176
|
+
switch (node.type) {
|
|
177
|
+
case utils_1.AST_NODE_TYPES.SpreadElement:
|
|
178
|
+
case utils_1.AST_NODE_TYPES.RestElement:
|
|
179
|
+
return OperatorPrecedence.Spread;
|
|
180
|
+
case utils_1.AST_NODE_TYPES.YieldExpression:
|
|
181
|
+
return OperatorPrecedence.Yield;
|
|
182
|
+
case utils_1.AST_NODE_TYPES.ConditionalExpression:
|
|
183
|
+
return OperatorPrecedence.Conditional;
|
|
184
|
+
case utils_1.AST_NODE_TYPES.SequenceExpression:
|
|
185
|
+
return OperatorPrecedence.Comma;
|
|
186
|
+
case utils_1.AST_NODE_TYPES.AssignmentExpression:
|
|
187
|
+
case utils_1.AST_NODE_TYPES.BinaryExpression:
|
|
188
|
+
case utils_1.AST_NODE_TYPES.LogicalExpression:
|
|
189
|
+
switch (node.operator) {
|
|
190
|
+
case '==':
|
|
191
|
+
case '+=':
|
|
192
|
+
case '-=':
|
|
193
|
+
case '**=':
|
|
194
|
+
case '*=':
|
|
195
|
+
case '/=':
|
|
196
|
+
case '%=':
|
|
197
|
+
case '<<=':
|
|
198
|
+
case '>>=':
|
|
199
|
+
case '>>>=':
|
|
200
|
+
case '&=':
|
|
201
|
+
case '^=':
|
|
202
|
+
case '|=':
|
|
203
|
+
case '||=':
|
|
204
|
+
case '&&=':
|
|
205
|
+
case '??=':
|
|
206
|
+
return OperatorPrecedence.Assignment;
|
|
207
|
+
default:
|
|
208
|
+
return getBinaryOperatorPrecedence(node.operator);
|
|
209
|
+
}
|
|
210
|
+
case utils_1.AST_NODE_TYPES.TSTypeAssertion:
|
|
211
|
+
case utils_1.AST_NODE_TYPES.TSNonNullExpression:
|
|
212
|
+
case utils_1.AST_NODE_TYPES.UnaryExpression:
|
|
213
|
+
case utils_1.AST_NODE_TYPES.AwaitExpression:
|
|
214
|
+
return OperatorPrecedence.Unary;
|
|
215
|
+
case utils_1.AST_NODE_TYPES.UpdateExpression:
|
|
216
|
+
// TODO: Should prefix `++` and `--` be moved to the `Update` precedence?
|
|
217
|
+
if (node.prefix) {
|
|
218
|
+
return OperatorPrecedence.Unary;
|
|
219
|
+
}
|
|
220
|
+
return OperatorPrecedence.Update;
|
|
221
|
+
case utils_1.AST_NODE_TYPES.ChainExpression:
|
|
222
|
+
return getOperatorPrecedenceForNode(node.expression);
|
|
223
|
+
case utils_1.AST_NODE_TYPES.CallExpression:
|
|
224
|
+
return OperatorPrecedence.LeftHandSide;
|
|
225
|
+
case utils_1.AST_NODE_TYPES.NewExpression:
|
|
226
|
+
return node.arguments.length > 0
|
|
227
|
+
? OperatorPrecedence.Member
|
|
228
|
+
: OperatorPrecedence.LeftHandSide;
|
|
229
|
+
case utils_1.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
230
|
+
case utils_1.AST_NODE_TYPES.MemberExpression:
|
|
231
|
+
case utils_1.AST_NODE_TYPES.MetaProperty:
|
|
232
|
+
return OperatorPrecedence.Member;
|
|
233
|
+
case utils_1.AST_NODE_TYPES.TSAsExpression:
|
|
234
|
+
return OperatorPrecedence.Relational;
|
|
235
|
+
case utils_1.AST_NODE_TYPES.ThisExpression:
|
|
236
|
+
case utils_1.AST_NODE_TYPES.Super:
|
|
237
|
+
case utils_1.AST_NODE_TYPES.Identifier:
|
|
238
|
+
case utils_1.AST_NODE_TYPES.PrivateIdentifier:
|
|
239
|
+
case utils_1.AST_NODE_TYPES.Literal:
|
|
240
|
+
case utils_1.AST_NODE_TYPES.ArrayExpression:
|
|
241
|
+
case utils_1.AST_NODE_TYPES.ObjectExpression:
|
|
242
|
+
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
|
243
|
+
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
244
|
+
case utils_1.AST_NODE_TYPES.ClassExpression:
|
|
245
|
+
case utils_1.AST_NODE_TYPES.TemplateLiteral:
|
|
246
|
+
case utils_1.AST_NODE_TYPES.JSXElement:
|
|
247
|
+
case utils_1.AST_NODE_TYPES.JSXFragment:
|
|
248
|
+
// we don't have nodes for these cases
|
|
249
|
+
// case SyntaxKind.ParenthesizedExpression:
|
|
250
|
+
// case SyntaxKind.OmittedExpression:
|
|
251
|
+
return OperatorPrecedence.Primary;
|
|
252
|
+
default:
|
|
253
|
+
return OperatorPrecedence.Invalid;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
exports.getOperatorPrecedenceForNode = getOperatorPrecedenceForNode;
|
|
174
257
|
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
|
|
175
258
|
switch (nodeKind) {
|
|
259
|
+
// A list of comma-separated expressions. This node is only created by transformations.
|
|
176
260
|
case typescript_1.SyntaxKind.CommaListExpression:
|
|
177
261
|
return OperatorPrecedence.Comma;
|
|
178
262
|
case typescript_1.SyntaxKind.SpreadElement:
|
|
@@ -261,42 +345,68 @@ exports.getOperatorPrecedence = getOperatorPrecedence;
|
|
|
261
345
|
function getBinaryOperatorPrecedence(kind) {
|
|
262
346
|
switch (kind) {
|
|
263
347
|
case typescript_1.SyntaxKind.QuestionQuestionToken:
|
|
348
|
+
case '??':
|
|
264
349
|
return OperatorPrecedence.Coalesce;
|
|
265
350
|
case typescript_1.SyntaxKind.BarBarToken:
|
|
351
|
+
case '||':
|
|
266
352
|
return OperatorPrecedence.LogicalOR;
|
|
267
353
|
case typescript_1.SyntaxKind.AmpersandAmpersandToken:
|
|
354
|
+
case '&&':
|
|
268
355
|
return OperatorPrecedence.LogicalAND;
|
|
269
356
|
case typescript_1.SyntaxKind.BarToken:
|
|
357
|
+
case '|':
|
|
270
358
|
return OperatorPrecedence.BitwiseOR;
|
|
271
359
|
case typescript_1.SyntaxKind.CaretToken:
|
|
360
|
+
case '^':
|
|
272
361
|
return OperatorPrecedence.BitwiseXOR;
|
|
273
362
|
case typescript_1.SyntaxKind.AmpersandToken:
|
|
363
|
+
case '&':
|
|
274
364
|
return OperatorPrecedence.BitwiseAND;
|
|
275
365
|
case typescript_1.SyntaxKind.EqualsEqualsToken:
|
|
366
|
+
case '==':
|
|
276
367
|
case typescript_1.SyntaxKind.ExclamationEqualsToken:
|
|
368
|
+
case '!=':
|
|
277
369
|
case typescript_1.SyntaxKind.EqualsEqualsEqualsToken:
|
|
370
|
+
case '===':
|
|
278
371
|
case typescript_1.SyntaxKind.ExclamationEqualsEqualsToken:
|
|
372
|
+
case '!==':
|
|
279
373
|
return OperatorPrecedence.Equality;
|
|
280
374
|
case typescript_1.SyntaxKind.LessThanToken:
|
|
375
|
+
case '<':
|
|
281
376
|
case typescript_1.SyntaxKind.GreaterThanToken:
|
|
377
|
+
case '>':
|
|
282
378
|
case typescript_1.SyntaxKind.LessThanEqualsToken:
|
|
379
|
+
case '<=':
|
|
283
380
|
case typescript_1.SyntaxKind.GreaterThanEqualsToken:
|
|
381
|
+
case '>=':
|
|
284
382
|
case typescript_1.SyntaxKind.InstanceOfKeyword:
|
|
383
|
+
case 'instanceof':
|
|
285
384
|
case typescript_1.SyntaxKind.InKeyword:
|
|
385
|
+
case 'in':
|
|
286
386
|
case typescript_1.SyntaxKind.AsKeyword:
|
|
387
|
+
// case 'as': -- we don't have a token for this
|
|
287
388
|
return OperatorPrecedence.Relational;
|
|
288
389
|
case typescript_1.SyntaxKind.LessThanLessThanToken:
|
|
390
|
+
case '<<':
|
|
289
391
|
case typescript_1.SyntaxKind.GreaterThanGreaterThanToken:
|
|
392
|
+
case '>>':
|
|
290
393
|
case typescript_1.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
|
394
|
+
case '>>>':
|
|
291
395
|
return OperatorPrecedence.Shift;
|
|
292
396
|
case typescript_1.SyntaxKind.PlusToken:
|
|
397
|
+
case '+':
|
|
293
398
|
case typescript_1.SyntaxKind.MinusToken:
|
|
399
|
+
case '-':
|
|
294
400
|
return OperatorPrecedence.Additive;
|
|
295
401
|
case typescript_1.SyntaxKind.AsteriskToken:
|
|
402
|
+
case '*':
|
|
296
403
|
case typescript_1.SyntaxKind.SlashToken:
|
|
404
|
+
case '/':
|
|
297
405
|
case typescript_1.SyntaxKind.PercentToken:
|
|
406
|
+
case '%':
|
|
298
407
|
return OperatorPrecedence.Multiplicative;
|
|
299
408
|
case typescript_1.SyntaxKind.AsteriskAsteriskToken:
|
|
409
|
+
case '**':
|
|
300
410
|
return OperatorPrecedence.Exponentiation;
|
|
301
411
|
}
|
|
302
412
|
// -1 is lower than all other precedences. Returning it will cause binary expression
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperatorPrecedence.js","sourceRoot":"","sources":["../../src/util/getOperatorPrecedence.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getOperatorPrecedence.js","sourceRoot":"","sources":["../../src/util/getOperatorPrecedence.ts"],"names":[],"mappings":";;;AACA,oDAA0D;AAC1D,2CAAwC;AAExC,IAAY,kBA8LX;AA9LD,WAAY,kBAAkB;IAC5B,cAA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I,CAAC;QACV,KAAK,uBAAU,CAAC,sCAAsC,CAAC;QACvD,KAAK,KAAK;YACR,OAAO,kBAAkB,CAAC,KAAK,CAAC;QAElC,KAAK,uBAAU,CAAC,SAAS,CAAC;QAC1B,KAAK,GAAG,CAAC;QACT,KAAK,uBAAU,CAAC,UAAU,CAAC;QAC3B,KAAK,GAAG;YACN,OAAO,kBAAkB,CAAC,QAAQ,CAAC;QAErC,KAAK,uBAAU,CAAC,aAAa,CAAC;QAC9B,KAAK,GAAG,CAAC;QACT,KAAK,uBAAU,CAAC,UAAU,CAAC;QAC3B,KAAK,GAAG,CAAC;QACT,KAAK,uBAAU,CAAC,YAAY,CAAC;QAC7B,KAAK,GAAG;YACN,OAAO,kBAAkB,CAAC,cAAc,CAAC;QAE3C,KAAK,uBAAU,CAAC,qBAAqB,CAAC;QACtC,KAAK,IAAI;YACP,OAAO,kBAAkB,CAAC,cAAc,CAAC;KAC5C;IAED,qFAAqF;IACrF,mBAAmB;IACnB,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AApFD,kEAoFC"}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getStringLength = void 0;
|
|
7
|
-
const
|
|
7
|
+
const graphemer_1 = __importDefault(require("graphemer"));
|
|
8
8
|
let splitter;
|
|
9
9
|
function isASCII(value) {
|
|
10
10
|
return /^[\u0020-\u007f]*$/u.test(value);
|
|
@@ -13,7 +13,7 @@ function getStringLength(value) {
|
|
|
13
13
|
if (isASCII(value)) {
|
|
14
14
|
return value.length;
|
|
15
15
|
}
|
|
16
|
-
splitter ??= new
|
|
16
|
+
splitter ??= new graphemer_1.default();
|
|
17
17
|
return splitter.countGraphemes(value);
|
|
18
18
|
}
|
|
19
19
|
exports.getStringLength = getStringLength;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStringLength.js","sourceRoot":"","sources":["../../src/util/getStringLength.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"getStringLength.js","sourceRoot":"","sources":["../../src/util/getStringLength.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAElC,IAAI,QAAmB,CAAC;AAExB,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,eAAe,CAAC,KAAa;IAC3C,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,MAAM,CAAC;KACrB;IAED,QAAQ,KAAK,IAAI,mBAAS,EAAE,CAAC;IAE7B,OAAO,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AARD,0CAQC"}
|
package/dist/util/misc.js
CHANGED
|
@@ -103,8 +103,7 @@ var MemberNameType;
|
|
|
103
103
|
MemberNameType[MemberNameType["Quoted"] = 2] = "Quoted";
|
|
104
104
|
MemberNameType[MemberNameType["Normal"] = 3] = "Normal";
|
|
105
105
|
MemberNameType[MemberNameType["Expression"] = 4] = "Expression";
|
|
106
|
-
})(MemberNameType || (MemberNameType = {}));
|
|
107
|
-
exports.MemberNameType = MemberNameType;
|
|
106
|
+
})(MemberNameType || (exports.MemberNameType = MemberNameType = {}));
|
|
108
107
|
/**
|
|
109
108
|
* Gets a string name representation of the name of the given MethodDefinition
|
|
110
109
|
* or PropertyDefinition node, with handling for computed property names.
|
package/dist/util/misc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/util/misc.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8DAAgE;AAEhE,oDAA0D;AAC1D,+CAAiC;AAEjC,MAAM,qBAAqB,GAAG;IAC5B,EAAE,CAAC,SAAS,CAAC,GAAG;IAChB,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ChB;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAY,EACZ,SAAoD;IAEpD,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAE7B,OAAO,GAAG,IAAI,CAAC,EAAE;QACf,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,IAAI,KAAK,EAAE;YACT,OAAO,GAAG,CAAC;SACZ;QACD,GAAG,EAAE,CAAC;KACP;IAED,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AA8BC,sCAAa;AA5Bf,SAAS,2BAA2B,CAClC,IAAuB,EACvB,IAAY;IAEZ,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,cAAc;QAC3C,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB;QAC9C,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB;QAC9C,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAClE,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,kBAAkB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAC1E,CAAC;AACJ,CAAC;AAeC,kEAA2B"}
|
package/docs/rules/README.md
CHANGED
|
@@ -13,11 +13,11 @@ See [Configs](/linting/configs) for how to enable recommended rules using config
|
|
|
13
13
|
|
|
14
14
|
import RulesTable from "@site/src/components/RulesTable";
|
|
15
15
|
|
|
16
|
-
<RulesTable />
|
|
16
|
+
<RulesTable ruleset="supported-rules" />
|
|
17
17
|
|
|
18
18
|
## Extension Rules
|
|
19
19
|
|
|
20
20
|
In some cases, ESLint provides a rule itself, but it doesn't support TypeScript syntax; either it crashes, or it ignores the syntax, or it falsely reports against it.
|
|
21
21
|
In these cases, we create what we call an extension rule; a rule within our plugin that has the same functionality, but also supports TypeScript.
|
|
22
22
|
|
|
23
|
-
<RulesTable
|
|
23
|
+
<RulesTable ruleset="extension-rules" />
|
package/docs/rules/ban-types.md
CHANGED
|
@@ -111,7 +111,9 @@ const defaultTypes = {
|
|
|
111
111
|
'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.',
|
|
112
112
|
'- If you want a type meaning "any object", you probably want `object` instead.',
|
|
113
113
|
'- If you want a type meaning "any value", you probably want `unknown` instead.',
|
|
114
|
+
'- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.',
|
|
114
115
|
].join('\n'),
|
|
116
|
+
suggest: ['object', 'unknown', 'NonNullable<unknown>'],
|
|
115
117
|
},
|
|
116
118
|
'{}': {
|
|
117
119
|
message: [
|
|
@@ -119,7 +121,14 @@ const defaultTypes = {
|
|
|
119
121
|
'- If you want a type meaning "any object", you probably want `object` instead.',
|
|
120
122
|
'- If you want a type meaning "any value", you probably want `unknown` instead.',
|
|
121
123
|
'- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.',
|
|
124
|
+
'- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.',
|
|
122
125
|
].join('\n'),
|
|
126
|
+
suggest: [
|
|
127
|
+
'object',
|
|
128
|
+
'unknown',
|
|
129
|
+
'Record<string, never>',
|
|
130
|
+
'NonNullable<unknown>',
|
|
131
|
+
],
|
|
123
132
|
},
|
|
124
133
|
};
|
|
125
134
|
```
|
|
@@ -139,6 +148,7 @@ The values can be:
|
|
|
139
148
|
- An object with the following properties:
|
|
140
149
|
- `message: string` - the message to display when the type is matched.
|
|
141
150
|
- `fixWith?: string` - a string to replace the banned type with when the fixer is run. If this is omitted, no fix will be done.
|
|
151
|
+
- `suggest?: string[]` - a list of suggested replacements for the banned type.
|
|
142
152
|
|
|
143
153
|
### `extendDefaults`
|
|
144
154
|
|
|
@@ -13,7 +13,7 @@ It adds support for TypeScript syntax.
|
|
|
13
13
|
|
|
14
14
|
See the [ESLint documentation](https://eslint.org/docs/rules/comma-dangle) for more details on the `comma-dangle` rule.
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Options
|
|
17
17
|
|
|
18
18
|
In addition to the options supported by the `comma-dangle` rule in ESLint core, the rule adds the following options:
|
|
19
19
|
|
|
@@ -56,7 +56,7 @@ export var fn = function (): number {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
// A return value of type string
|
|
59
|
-
export var arrowFn = (
|
|
59
|
+
export var arrowFn = (): string => 'test';
|
|
60
60
|
|
|
61
61
|
// All arguments should be typed
|
|
62
62
|
export var arrowFn = (arg: string): string => `test ${arg}`;
|
|
@@ -11,24 +11,14 @@ description: 'Require empty lines around comments.'
|
|
|
11
11
|
This rule extends the base [`eslint/lines-around-comment`](https://eslint.org/docs/rules/lines-around-comment) rule.
|
|
12
12
|
It adds support for TypeScript syntax.
|
|
13
13
|
|
|
14
|
-
See the [ESLint documentation](https://eslint.org/docs/rules/lines-around-comment) for more details on the `
|
|
15
|
-
|
|
16
|
-
## Rule Changes
|
|
17
|
-
|
|
18
|
-
```jsonc
|
|
19
|
-
{
|
|
20
|
-
// note you must disable the base rule as it can report incorrect errors
|
|
21
|
-
"lines-around-comment": "off",
|
|
22
|
-
"@typescript-eslint/lines-around-comment": ["error"]
|
|
23
|
-
}
|
|
24
|
-
```
|
|
14
|
+
See the [ESLint documentation](https://eslint.org/docs/rules/lines-around-comment) for more details on the `lines-around-comment` rule.
|
|
25
15
|
|
|
26
16
|
## Options
|
|
27
17
|
|
|
28
18
|
In addition to the options supported by the `lines-around-comment` rule in ESLint core, the rule adds the following options:
|
|
29
19
|
|
|
30
|
-
- `allowEnumEnd: true` doesn't require a blank line after an
|
|
31
|
-
- `allowEnumStart: true` doesn't require a blank line before an
|
|
20
|
+
- `allowEnumEnd: true` doesn't require a blank line after an enum body block end
|
|
21
|
+
- `allowEnumStart: true` doesn't require a blank line before an enum body block start
|
|
32
22
|
- `allowInterfaceEnd: true` doesn't require a blank line before an interface body block end
|
|
33
23
|
- `allowInterfaceStart: true` doesn't require a blank line after an interface body block start
|
|
34
24
|
- `allowModuleEnd: true` doesn't require a blank line before a module body block end
|
|
@@ -104,10 +104,10 @@ For information about how each selector is applied, see ["How does the rule eval
|
|
|
104
104
|
The `format` option defines the allowed formats for the identifier. This option accepts an array of the following values, and the identifier can match any of them:
|
|
105
105
|
|
|
106
106
|
- `camelCase` - standard camelCase format - no underscores are allowed between characters, and consecutive capitals are allowed (i.e. both `myID` and `myId` are valid).
|
|
107
|
-
- `strictCamelCase` - same as `camelCase`, but consecutive capitals are not allowed (i.e. `myId` is valid, but `myID` is not).
|
|
108
107
|
- `PascalCase` - same as `camelCase`, except the first character must be upper-case.
|
|
109
|
-
- `StrictPascalCase` - same as `strictCamelCase`, except the first character must be upper-case.
|
|
110
108
|
- `snake_case` - standard snake_case format - all characters must be lower-case, and underscores are allowed.
|
|
109
|
+
- `strictCamelCase` - same as `camelCase`, but consecutive capitals are not allowed (i.e. `myId` is valid, but `myID` is not).
|
|
110
|
+
- `StrictPascalCase` - same as `strictCamelCase`, except the first character must be upper-case.
|
|
111
111
|
- `UPPER_CASE` - same as `snake_case`, except all characters must be upper-case.
|
|
112
112
|
|
|
113
113
|
Instead of an array, you may also pass `null`. This signifies "this selector shall not have its format checked".
|
|
@@ -118,8 +118,8 @@ This can be useful if you want to enforce no particular format for a specific se
|
|
|
118
118
|
The `custom` option defines a custom regex that the identifier must (or must not) match. This option allows you to have a bit more finer-grained control over identifiers, letting you ban (or force) certain patterns and substrings.
|
|
119
119
|
Accepts an object with the following properties:
|
|
120
120
|
|
|
121
|
-
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
122
121
|
- `match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`.
|
|
122
|
+
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
123
123
|
|
|
124
124
|
#### `filter`
|
|
125
125
|
|
|
@@ -129,8 +129,8 @@ You can use this to include or exclude specific identifiers from specific config
|
|
|
129
129
|
|
|
130
130
|
Accepts an object with the following properties:
|
|
131
131
|
|
|
132
|
-
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
133
132
|
- `match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`.
|
|
133
|
+
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
134
134
|
|
|
135
135
|
Alternatively, `filter` accepts a regular expression (anything accepted into `new RegExp(filter)`). In this case, it's treated as if you had passed an object with the regex and `match: true`.
|
|
136
136
|
|
|
@@ -138,12 +138,12 @@ Alternatively, `filter` accepts a regular expression (anything accepted into `ne
|
|
|
138
138
|
|
|
139
139
|
The `leadingUnderscore` / `trailingUnderscore` options control whether leading/trailing underscores are considered valid. Accepts one of the following values:
|
|
140
140
|
|
|
141
|
-
- `forbid` - a leading/trailing underscore is not allowed at all.
|
|
142
|
-
- `require` - a single leading/trailing underscore must be included.
|
|
143
|
-
- `requireDouble` - two leading/trailing underscores must be included.
|
|
144
141
|
- `allow` - existence of a single leading/trailing underscore is not explicitly enforced.
|
|
145
142
|
- `allowDouble` - existence of a double leading/trailing underscore is not explicitly enforced.
|
|
146
143
|
- `allowSingleOrDouble` - existence of a single or a double leading/trailing underscore is not explicitly enforced.
|
|
144
|
+
- `forbid` - a leading/trailing underscore is not allowed at all.
|
|
145
|
+
- `require` - a single leading/trailing underscore must be included.
|
|
146
|
+
- `requireDouble` - two leading/trailing underscores must be included.
|
|
147
147
|
|
|
148
148
|
#### `prefix` / `suffix`
|
|
149
149
|
|
|
@@ -163,27 +163,27 @@ If these are provided, the identifier must start with one of the provided values
|
|
|
163
163
|
- The name must match _all_ of the modifiers.
|
|
164
164
|
- For example, if you provide `{ modifiers: ['private','readonly','static'] }`, then it will only match something that is `private static readonly`, and something that is just `private` will not match.
|
|
165
165
|
- The following `modifiers` are allowed:
|
|
166
|
+
- `abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier.
|
|
167
|
+
- `async` - matches any method, function, or function variable which is async via the `async` keyword (e.g. does not match functions that return promises without using `async` keyword)
|
|
166
168
|
- `const` - matches a variable declared as being `const` (`const x = 1`).
|
|
167
169
|
- `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
|
|
168
170
|
- Note that this does not match renamed destructured properties (`const {x: y, a: b = 2}`).
|
|
169
|
-
- `global` - matches a variable/function declared in the top-level scope.
|
|
170
171
|
- `exported` - matches anything that is exported from the module.
|
|
171
|
-
- `
|
|
172
|
-
- `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
|
|
173
|
-
- `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
|
|
174
|
-
- `abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier.
|
|
172
|
+
- `global` - matches a variable/function declared in the top-level scope.
|
|
175
173
|
- `#private` - matches any member with a private identifier (an identifier that starts with `#`)
|
|
176
|
-
- `
|
|
174
|
+
- `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
|
|
175
|
+
- `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
|
|
176
|
+
- `unused` - matches anything that is not used.
|
|
177
177
|
- `types` allows you to specify which types to match. This option supports simple, primitive types only (`array`,`boolean`,`function`,`number`,`string`).
|
|
178
178
|
- The name must match _one_ of the types.
|
|
179
179
|
- **_NOTE - Using this option will require that you lint with type information._**
|
|
180
180
|
- For example, this lets you do things like enforce that `boolean` variables are prefixed with a verb.
|
|
181
181
|
- The following `types` are allowed:
|
|
182
|
-
- `boolean` matches any type assignable to `boolean | null | undefined`
|
|
183
|
-
- `string` matches any type assignable to `string | null | undefined`
|
|
184
|
-
- `number` matches any type assignable to `number | null | undefined`
|
|
185
182
|
- `array` matches any type assignable to `Array<unknown> | null | undefined`
|
|
183
|
+
- `boolean` matches any type assignable to `boolean | null | undefined`
|
|
186
184
|
- `function` matches any type assignable to `Function | null | undefined`
|
|
185
|
+
- `number` matches any type assignable to `number | null | undefined`
|
|
186
|
+
- `string` matches any type assignable to `string | null | undefined`
|
|
187
187
|
|
|
188
188
|
The ordering of selectors does not matter. The implementation will automatically sort the selectors to ensure they match from most-specific to least specific. It will keep checking selectors in that order until it finds one that matches the name. See ["How does the rule automatically order selectors?"](#how-does-the-rule-automatically-order-selectors)
|
|
189
189
|
|
|
@@ -195,57 +195,57 @@ There are two types of selectors, individual selectors, and grouped selectors.
|
|
|
195
195
|
|
|
196
196
|
Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors.
|
|
197
197
|
|
|
198
|
-
- `
|
|
199
|
-
- Allowed `modifiers`: `
|
|
198
|
+
- `accessor` - matches any accessor.
|
|
199
|
+
- Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
|
|
200
200
|
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
201
|
-
- `
|
|
202
|
-
- Allowed `modifiers`: `
|
|
201
|
+
- `class` - matches any class declaration.
|
|
202
|
+
- Allowed `modifiers`: `abstract`, `exported`, `unused`.
|
|
203
203
|
- Allowed `types`: none.
|
|
204
|
-
- `parameter` - matches any function parameter. Does not match parameter properties.
|
|
205
|
-
- Allowed `modifiers`: `destructured`, `unused`.
|
|
206
|
-
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
|
|
207
|
-
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
|
|
208
|
-
- Allowed `modifiers`: `abstract`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
209
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
210
|
-
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
|
|
211
|
-
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
212
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
213
|
-
- `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
|
|
214
|
-
- Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`.
|
|
215
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
216
|
-
- `parameterProperty` - matches any parameter property.
|
|
217
|
-
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
|
|
218
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
219
204
|
- `classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
220
205
|
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
|
|
221
206
|
- Allowed `types`: none.
|
|
222
|
-
- `
|
|
223
|
-
- Allowed `modifiers`: `
|
|
224
|
-
- Allowed `types`: none.
|
|
225
|
-
- `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
226
|
-
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
227
|
-
- Allowed `types`: none.
|
|
228
|
-
- `accessor` - matches any accessor.
|
|
229
|
-
- Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
|
|
207
|
+
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
|
|
208
|
+
- Allowed `modifiers`: `abstract`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
230
209
|
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
210
|
+
- `enum` - matches any enum declaration.
|
|
211
|
+
- Allowed `modifiers`: `exported`, `unused`.
|
|
212
|
+
- Allowed `types`: none.
|
|
231
213
|
- `enumMember` - matches any enum member.
|
|
232
214
|
- Allowed `modifiers`: `requiresQuotes`.
|
|
233
215
|
- Allowed `types`: none.
|
|
234
|
-
- `
|
|
235
|
-
- Allowed `modifiers`: `
|
|
216
|
+
- `function` - matches any named function declaration or named function expression.
|
|
217
|
+
- Allowed `modifiers`: `async`, `exported`, `global`, `unused`.
|
|
236
218
|
- Allowed `types`: none.
|
|
237
219
|
- `interface` - matches any interface declaration.
|
|
238
220
|
- Allowed `modifiers`: `exported`, `unused`.
|
|
239
221
|
- Allowed `types`: none.
|
|
222
|
+
- `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
223
|
+
- Allowed `modifiers`: `async`, `public`, `requiresQuotes`.
|
|
224
|
+
- Allowed `types`: none.
|
|
225
|
+
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
|
|
226
|
+
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
227
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
228
|
+
- `parameter` - matches any function parameter. Does not match parameter properties.
|
|
229
|
+
- Allowed `modifiers`: `destructured`, `unused`.
|
|
230
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
231
|
+
- `parameterProperty` - matches any parameter property.
|
|
232
|
+
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
|
|
233
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
240
234
|
- `typeAlias` - matches any type alias declaration.
|
|
241
235
|
- Allowed `modifiers`: `exported`, `unused`.
|
|
242
236
|
- Allowed `types`: none.
|
|
243
|
-
- `
|
|
244
|
-
- Allowed `modifiers`: `
|
|
237
|
+
- `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
238
|
+
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
245
239
|
- Allowed `types`: none.
|
|
246
240
|
- `typeParameter` - matches any generic type parameter declaration.
|
|
247
241
|
- Allowed `modifiers`: `unused`.
|
|
248
242
|
- Allowed `types`: none.
|
|
243
|
+
- `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
|
|
244
|
+
- Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`.
|
|
245
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
246
|
+
- `variable` - matches any `const` / `let` / `var` variable name.
|
|
247
|
+
- Allowed `modifiers`: `async`, `const`, `destructured`, `exported`, `global`, `unused`.
|
|
248
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
249
249
|
|
|
250
250
|
##### Group Selectors
|
|
251
251
|
|
|
@@ -254,20 +254,20 @@ Group Selectors are provided for convenience, and essentially bundle up sets of
|
|
|
254
254
|
- `default` - matches everything.
|
|
255
255
|
- Allowed `modifiers`: all modifiers.
|
|
256
256
|
- Allowed `types`: none.
|
|
257
|
-
- `variableLike` - matches the same as `function`, `parameter` and `variable`.
|
|
258
|
-
- Allowed `modifiers`: `async`, `unused`.
|
|
259
|
-
- Allowed `types`: none.
|
|
260
257
|
- `memberLike` - matches the same as `accessor`, `enumMember`, `method`, `parameterProperty`, `property`.
|
|
261
258
|
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
262
259
|
- Allowed `types`: none.
|
|
263
|
-
- `
|
|
264
|
-
- Allowed `modifiers`: `abstract`, `
|
|
260
|
+
- `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`.
|
|
261
|
+
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
265
262
|
- Allowed `types`: none.
|
|
266
263
|
- `property` - matches the same as `classProperty`, `objectLiteralProperty`, `typeProperty`.
|
|
267
264
|
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
268
265
|
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
269
|
-
- `
|
|
270
|
-
- Allowed `modifiers`: `abstract`, `
|
|
266
|
+
- `typeLike` - matches the same as `class`, `enum`, `interface`, `typeAlias`, `typeParameter`.
|
|
267
|
+
- Allowed `modifiers`: `abstract`, `unused`.
|
|
268
|
+
- Allowed `types`: none.
|
|
269
|
+
- `variableLike` - matches the same as `function`, `parameter` and `variable`.
|
|
270
|
+
- Allowed `modifiers`: `async`, `unused`.
|
|
271
271
|
- Allowed `types`: none.
|
|
272
272
|
|
|
273
273
|
## FAQ
|
|
@@ -278,18 +278,18 @@ This is a big rule, and there's a lot of docs. Here are a few clarifications tha
|
|
|
278
278
|
|
|
279
279
|
Each selector is checked in the following way:
|
|
280
280
|
|
|
281
|
-
1. check the `selector`
|
|
282
|
-
1. if `selector` is one individual selector → the name's type must be of that type.
|
|
283
|
-
1. if `selector` is a group selector → the name's type must be one of the grouped types.
|
|
284
|
-
1. if `selector` is an array of selectors → apply the above for each selector in the array.
|
|
285
281
|
1. check the `filter`
|
|
286
282
|
1. if `filter` is omitted → skip this step.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
283
|
+
2. if the name matches the `filter` → continue evaluating this selector.
|
|
284
|
+
3. if the name does not match the `filter` → skip this selector and continue to the next selector.
|
|
285
|
+
2. check the `selector`
|
|
286
|
+
1. if `selector` is one individual selector → the name's type must be of that type.
|
|
287
|
+
2. if `selector` is a group selector → the name's type must be one of the grouped types.
|
|
288
|
+
3. if `selector` is an array of selectors → apply the above for each selector in the array.
|
|
289
|
+
3. check the `types`
|
|
290
290
|
1. if `types` is omitted → skip this step.
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
2. if the name has a type in `types` → continue evaluating this selector.
|
|
292
|
+
3. if the name does not have a type in `types` → skip this selector and continue to the next selector.
|
|
293
293
|
|
|
294
294
|
A name is considered to pass the config if it:
|
|
295
295
|
|