@so1ve/eslint-plugin 0.43.1 → 0.44.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/dist/index.cjs +133 -11
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +121 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
const utils = require('@typescript-eslint/utils');
|
|
4
4
|
const reactivity = require('@vue/reactivity');
|
|
5
|
+
const util = require('@typescript-eslint/utils/dist/ast-utils');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
const n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
n[k] = e[k];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
n.default = e;
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const util__namespace = /*#__PURE__*/_interopNamespaceDefault(util);
|
|
5
19
|
|
|
6
20
|
const createEslintRule = utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
7
21
|
|
|
8
|
-
const RULE_NAME$
|
|
22
|
+
const RULE_NAME$7 = "generic-spacing";
|
|
9
23
|
const genericSpacing = createEslintRule({
|
|
10
|
-
name: RULE_NAME$
|
|
24
|
+
name: RULE_NAME$7,
|
|
11
25
|
meta: {
|
|
12
26
|
type: "layout",
|
|
13
27
|
docs: {
|
|
@@ -255,9 +269,9 @@ const genericSpacing = createEslintRule({
|
|
|
255
269
|
}
|
|
256
270
|
});
|
|
257
271
|
|
|
258
|
-
const RULE_NAME$
|
|
272
|
+
const RULE_NAME$6 = "import-dedupe";
|
|
259
273
|
const importDedupe = createEslintRule({
|
|
260
|
-
name: RULE_NAME$
|
|
274
|
+
name: RULE_NAME$6,
|
|
261
275
|
meta: {
|
|
262
276
|
type: "problem",
|
|
263
277
|
docs: {
|
|
@@ -306,9 +320,9 @@ const importDedupe = createEslintRule({
|
|
|
306
320
|
});
|
|
307
321
|
|
|
308
322
|
const operatorOrAnyBracketOrKeywordRE = /^(\||&|\*|\+|\-|\/|%|<|>|<=|>=|==|!=|===|!==|\[|\(|\{|as|extends|implements|keyof|new|readonly|typeof|unique|unknown)/;
|
|
309
|
-
const RULE_NAME$
|
|
323
|
+
const RULE_NAME$5 = "space-between-generic-and-paren";
|
|
310
324
|
const spaceBetweenGenericAndParen = createEslintRule({
|
|
311
|
-
name: RULE_NAME$
|
|
325
|
+
name: RULE_NAME$5,
|
|
312
326
|
meta: {
|
|
313
327
|
type: "layout",
|
|
314
328
|
docs: {
|
|
@@ -382,9 +396,9 @@ const spaceBetweenGenericAndParen = createEslintRule({
|
|
|
382
396
|
}
|
|
383
397
|
});
|
|
384
398
|
|
|
385
|
-
const RULE_NAME$
|
|
399
|
+
const RULE_NAME$4 = "no-spaces-before-paren";
|
|
386
400
|
const noSpacesBeforeParen = createEslintRule({
|
|
387
|
-
name: RULE_NAME$
|
|
401
|
+
name: RULE_NAME$4,
|
|
388
402
|
meta: {
|
|
389
403
|
type: "layout",
|
|
390
404
|
docs: {
|
|
@@ -483,9 +497,9 @@ const noSpacesBeforeParen = createEslintRule({
|
|
|
483
497
|
}
|
|
484
498
|
});
|
|
485
499
|
|
|
486
|
-
const RULE_NAME$
|
|
500
|
+
const RULE_NAME$3 = "space-in-empty-block";
|
|
487
501
|
const spaceInEmptyBlock = createEslintRule({
|
|
488
|
-
name: RULE_NAME$
|
|
502
|
+
name: RULE_NAME$3,
|
|
489
503
|
meta: {
|
|
490
504
|
type: "layout",
|
|
491
505
|
docs: {
|
|
@@ -550,6 +564,113 @@ const spaceInEmptyBlock = createEslintRule({
|
|
|
550
564
|
}
|
|
551
565
|
});
|
|
552
566
|
|
|
567
|
+
const RULE_NAME$2 = "space-before-function-paren";
|
|
568
|
+
const spaceBeforeFunctionParen = createEslintRule({
|
|
569
|
+
name: RULE_NAME$2,
|
|
570
|
+
meta: {
|
|
571
|
+
type: "layout",
|
|
572
|
+
docs: {
|
|
573
|
+
description: "Enforce consistent spacing before function parenthesis",
|
|
574
|
+
recommended: false,
|
|
575
|
+
extendsBaseRule: true
|
|
576
|
+
},
|
|
577
|
+
fixable: "whitespace",
|
|
578
|
+
schema: [
|
|
579
|
+
{
|
|
580
|
+
oneOf: [
|
|
581
|
+
{
|
|
582
|
+
enum: ["always", "never"]
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
type: "object",
|
|
586
|
+
properties: {
|
|
587
|
+
anonymous: {
|
|
588
|
+
enum: ["always", "never", "ignore"]
|
|
589
|
+
},
|
|
590
|
+
named: {
|
|
591
|
+
enum: ["always", "never", "ignore"]
|
|
592
|
+
},
|
|
593
|
+
asyncArrow: {
|
|
594
|
+
enum: ["always", "never", "ignore"]
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
additionalProperties: false
|
|
598
|
+
}
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
],
|
|
602
|
+
messages: {
|
|
603
|
+
unexpected: "Unexpected space before function parentheses.",
|
|
604
|
+
missing: "Missing space before function parentheses."
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
defaultOptions: ["always"],
|
|
608
|
+
create(context, [firstOption]) {
|
|
609
|
+
const sourceCode = context.getSourceCode();
|
|
610
|
+
const baseConfig = typeof firstOption === "string" ? firstOption : "always";
|
|
611
|
+
const overrideConfig = typeof firstOption === "object" ? firstOption : {};
|
|
612
|
+
function isNamedFunction(node) {
|
|
613
|
+
if (node.id != null) {
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
const parent = node.parent;
|
|
617
|
+
return parent.type === utils.AST_NODE_TYPES.MethodDefinition || parent.type === utils.AST_NODE_TYPES.TSAbstractMethodDefinition || parent.type === utils.AST_NODE_TYPES.Property && (parent.kind === "get" || parent.kind === "set" || parent.method);
|
|
618
|
+
}
|
|
619
|
+
function getConfigForFunction(node) {
|
|
620
|
+
if (node.type === utils.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
621
|
+
if (node.async && util__namespace.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
|
|
622
|
+
return overrideConfig.asyncArrow ?? baseConfig;
|
|
623
|
+
}
|
|
624
|
+
} else if (isNamedFunction(node)) {
|
|
625
|
+
return overrideConfig.named ?? baseConfig;
|
|
626
|
+
} else if (!node.generator) {
|
|
627
|
+
return overrideConfig.anonymous ?? baseConfig;
|
|
628
|
+
}
|
|
629
|
+
return "ignore";
|
|
630
|
+
}
|
|
631
|
+
function checkFunction(node) {
|
|
632
|
+
const functionConfig = getConfigForFunction(node);
|
|
633
|
+
if (functionConfig === "ignore") {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
let leftToken, rightToken;
|
|
637
|
+
if (node.typeParameters) {
|
|
638
|
+
leftToken = sourceCode.getLastToken(node.typeParameters);
|
|
639
|
+
rightToken = sourceCode.getTokenAfter(leftToken);
|
|
640
|
+
} else {
|
|
641
|
+
rightToken = sourceCode.getFirstToken(node, util__namespace.isOpeningParenToken);
|
|
642
|
+
leftToken = sourceCode.getTokenBefore(rightToken);
|
|
643
|
+
}
|
|
644
|
+
const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken);
|
|
645
|
+
if (hasSpacing && functionConfig === "never") {
|
|
646
|
+
context.report({
|
|
647
|
+
node,
|
|
648
|
+
loc: {
|
|
649
|
+
start: leftToken.loc.end,
|
|
650
|
+
end: rightToken.loc.start
|
|
651
|
+
},
|
|
652
|
+
messageId: "unexpected",
|
|
653
|
+
fix: (fixer) => fixer.removeRange([leftToken.range[1], rightToken.range[0]])
|
|
654
|
+
});
|
|
655
|
+
} else if (!hasSpacing && functionConfig === "always" && !node.typeParameters) {
|
|
656
|
+
context.report({
|
|
657
|
+
node,
|
|
658
|
+
loc: rightToken.loc,
|
|
659
|
+
messageId: "missing",
|
|
660
|
+
fix: (fixer) => fixer.insertTextAfter(leftToken, " ")
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
ArrowFunctionExpression: checkFunction,
|
|
666
|
+
FunctionDeclaration: checkFunction,
|
|
667
|
+
FunctionExpression: checkFunction,
|
|
668
|
+
TSEmptyBodyFunctionExpression: checkFunction,
|
|
669
|
+
TSDeclareFunction: checkFunction
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
|
|
553
674
|
const RULE_NAME$1 = "semi-spacing";
|
|
554
675
|
const semiSpacing = createEslintRule({
|
|
555
676
|
name: RULE_NAME$1,
|
|
@@ -656,7 +777,8 @@ const index = {
|
|
|
656
777
|
"space-in-empty-block": spaceInEmptyBlock,
|
|
657
778
|
"semi-spacing": semiSpacing,
|
|
658
779
|
"no-inline-type-import": noInlineTypeImport,
|
|
659
|
-
"no-spaces-before-paren": noSpacesBeforeParen
|
|
780
|
+
"no-spaces-before-paren": noSpacesBeforeParen,
|
|
781
|
+
"space-before-function-paren": spaceBeforeFunctionParen
|
|
660
782
|
}
|
|
661
783
|
};
|
|
662
784
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_dist_ts_eslint_Rule from '@typescript-eslint/utils/dist/ts-eslint/Rule';
|
|
2
2
|
|
|
3
|
+
type Option = "never" | "always";
|
|
4
|
+
type FuncOption = Option | "ignore";
|
|
5
|
+
type Options = [
|
|
6
|
+
Option | {
|
|
7
|
+
anonymous?: FuncOption;
|
|
8
|
+
named?: FuncOption;
|
|
9
|
+
asyncArrow?: FuncOption;
|
|
10
|
+
}
|
|
11
|
+
];
|
|
12
|
+
type MessageIds = "unexpected" | "missing";
|
|
13
|
+
|
|
3
14
|
declare const _default: {
|
|
4
15
|
rules: {
|
|
5
16
|
"import-dedupe": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"importDedupe", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
@@ -9,6 +20,7 @@ declare const _default: {
|
|
|
9
20
|
"semi-spacing": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noSpaceBeforeSemi", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
10
21
|
"no-inline-type-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noInlineTypeImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
11
22
|
"no-spaces-before-paren": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noSpacesBeforeParen", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
23
|
+
"space-before-function-paren": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<MessageIds, Options, _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
12
24
|
};
|
|
13
25
|
};
|
|
14
26
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
1
|
+
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
2
|
import { ref, computed } from '@vue/reactivity';
|
|
3
|
+
import * as util from '@typescript-eslint/utils/dist/ast-utils';
|
|
3
4
|
|
|
4
5
|
const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
5
6
|
|
|
6
|
-
const RULE_NAME$
|
|
7
|
+
const RULE_NAME$7 = "generic-spacing";
|
|
7
8
|
const genericSpacing = createEslintRule({
|
|
8
|
-
name: RULE_NAME$
|
|
9
|
+
name: RULE_NAME$7,
|
|
9
10
|
meta: {
|
|
10
11
|
type: "layout",
|
|
11
12
|
docs: {
|
|
@@ -253,9 +254,9 @@ const genericSpacing = createEslintRule({
|
|
|
253
254
|
}
|
|
254
255
|
});
|
|
255
256
|
|
|
256
|
-
const RULE_NAME$
|
|
257
|
+
const RULE_NAME$6 = "import-dedupe";
|
|
257
258
|
const importDedupe = createEslintRule({
|
|
258
|
-
name: RULE_NAME$
|
|
259
|
+
name: RULE_NAME$6,
|
|
259
260
|
meta: {
|
|
260
261
|
type: "problem",
|
|
261
262
|
docs: {
|
|
@@ -304,9 +305,9 @@ const importDedupe = createEslintRule({
|
|
|
304
305
|
});
|
|
305
306
|
|
|
306
307
|
const operatorOrAnyBracketOrKeywordRE = /^(\||&|\*|\+|\-|\/|%|<|>|<=|>=|==|!=|===|!==|\[|\(|\{|as|extends|implements|keyof|new|readonly|typeof|unique|unknown)/;
|
|
307
|
-
const RULE_NAME$
|
|
308
|
+
const RULE_NAME$5 = "space-between-generic-and-paren";
|
|
308
309
|
const spaceBetweenGenericAndParen = createEslintRule({
|
|
309
|
-
name: RULE_NAME$
|
|
310
|
+
name: RULE_NAME$5,
|
|
310
311
|
meta: {
|
|
311
312
|
type: "layout",
|
|
312
313
|
docs: {
|
|
@@ -380,9 +381,9 @@ const spaceBetweenGenericAndParen = createEslintRule({
|
|
|
380
381
|
}
|
|
381
382
|
});
|
|
382
383
|
|
|
383
|
-
const RULE_NAME$
|
|
384
|
+
const RULE_NAME$4 = "no-spaces-before-paren";
|
|
384
385
|
const noSpacesBeforeParen = createEslintRule({
|
|
385
|
-
name: RULE_NAME$
|
|
386
|
+
name: RULE_NAME$4,
|
|
386
387
|
meta: {
|
|
387
388
|
type: "layout",
|
|
388
389
|
docs: {
|
|
@@ -481,9 +482,9 @@ const noSpacesBeforeParen = createEslintRule({
|
|
|
481
482
|
}
|
|
482
483
|
});
|
|
483
484
|
|
|
484
|
-
const RULE_NAME$
|
|
485
|
+
const RULE_NAME$3 = "space-in-empty-block";
|
|
485
486
|
const spaceInEmptyBlock = createEslintRule({
|
|
486
|
-
name: RULE_NAME$
|
|
487
|
+
name: RULE_NAME$3,
|
|
487
488
|
meta: {
|
|
488
489
|
type: "layout",
|
|
489
490
|
docs: {
|
|
@@ -548,6 +549,113 @@ const spaceInEmptyBlock = createEslintRule({
|
|
|
548
549
|
}
|
|
549
550
|
});
|
|
550
551
|
|
|
552
|
+
const RULE_NAME$2 = "space-before-function-paren";
|
|
553
|
+
const spaceBeforeFunctionParen = createEslintRule({
|
|
554
|
+
name: RULE_NAME$2,
|
|
555
|
+
meta: {
|
|
556
|
+
type: "layout",
|
|
557
|
+
docs: {
|
|
558
|
+
description: "Enforce consistent spacing before function parenthesis",
|
|
559
|
+
recommended: false,
|
|
560
|
+
extendsBaseRule: true
|
|
561
|
+
},
|
|
562
|
+
fixable: "whitespace",
|
|
563
|
+
schema: [
|
|
564
|
+
{
|
|
565
|
+
oneOf: [
|
|
566
|
+
{
|
|
567
|
+
enum: ["always", "never"]
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
type: "object",
|
|
571
|
+
properties: {
|
|
572
|
+
anonymous: {
|
|
573
|
+
enum: ["always", "never", "ignore"]
|
|
574
|
+
},
|
|
575
|
+
named: {
|
|
576
|
+
enum: ["always", "never", "ignore"]
|
|
577
|
+
},
|
|
578
|
+
asyncArrow: {
|
|
579
|
+
enum: ["always", "never", "ignore"]
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
additionalProperties: false
|
|
583
|
+
}
|
|
584
|
+
]
|
|
585
|
+
}
|
|
586
|
+
],
|
|
587
|
+
messages: {
|
|
588
|
+
unexpected: "Unexpected space before function parentheses.",
|
|
589
|
+
missing: "Missing space before function parentheses."
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
defaultOptions: ["always"],
|
|
593
|
+
create(context, [firstOption]) {
|
|
594
|
+
const sourceCode = context.getSourceCode();
|
|
595
|
+
const baseConfig = typeof firstOption === "string" ? firstOption : "always";
|
|
596
|
+
const overrideConfig = typeof firstOption === "object" ? firstOption : {};
|
|
597
|
+
function isNamedFunction(node) {
|
|
598
|
+
if (node.id != null) {
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
const parent = node.parent;
|
|
602
|
+
return parent.type === AST_NODE_TYPES.MethodDefinition || parent.type === AST_NODE_TYPES.TSAbstractMethodDefinition || parent.type === AST_NODE_TYPES.Property && (parent.kind === "get" || parent.kind === "set" || parent.method);
|
|
603
|
+
}
|
|
604
|
+
function getConfigForFunction(node) {
|
|
605
|
+
if (node.type === AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
606
|
+
if (node.async && util.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
|
|
607
|
+
return overrideConfig.asyncArrow ?? baseConfig;
|
|
608
|
+
}
|
|
609
|
+
} else if (isNamedFunction(node)) {
|
|
610
|
+
return overrideConfig.named ?? baseConfig;
|
|
611
|
+
} else if (!node.generator) {
|
|
612
|
+
return overrideConfig.anonymous ?? baseConfig;
|
|
613
|
+
}
|
|
614
|
+
return "ignore";
|
|
615
|
+
}
|
|
616
|
+
function checkFunction(node) {
|
|
617
|
+
const functionConfig = getConfigForFunction(node);
|
|
618
|
+
if (functionConfig === "ignore") {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
let leftToken, rightToken;
|
|
622
|
+
if (node.typeParameters) {
|
|
623
|
+
leftToken = sourceCode.getLastToken(node.typeParameters);
|
|
624
|
+
rightToken = sourceCode.getTokenAfter(leftToken);
|
|
625
|
+
} else {
|
|
626
|
+
rightToken = sourceCode.getFirstToken(node, util.isOpeningParenToken);
|
|
627
|
+
leftToken = sourceCode.getTokenBefore(rightToken);
|
|
628
|
+
}
|
|
629
|
+
const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken);
|
|
630
|
+
if (hasSpacing && functionConfig === "never") {
|
|
631
|
+
context.report({
|
|
632
|
+
node,
|
|
633
|
+
loc: {
|
|
634
|
+
start: leftToken.loc.end,
|
|
635
|
+
end: rightToken.loc.start
|
|
636
|
+
},
|
|
637
|
+
messageId: "unexpected",
|
|
638
|
+
fix: (fixer) => fixer.removeRange([leftToken.range[1], rightToken.range[0]])
|
|
639
|
+
});
|
|
640
|
+
} else if (!hasSpacing && functionConfig === "always" && !node.typeParameters) {
|
|
641
|
+
context.report({
|
|
642
|
+
node,
|
|
643
|
+
loc: rightToken.loc,
|
|
644
|
+
messageId: "missing",
|
|
645
|
+
fix: (fixer) => fixer.insertTextAfter(leftToken, " ")
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return {
|
|
650
|
+
ArrowFunctionExpression: checkFunction,
|
|
651
|
+
FunctionDeclaration: checkFunction,
|
|
652
|
+
FunctionExpression: checkFunction,
|
|
653
|
+
TSEmptyBodyFunctionExpression: checkFunction,
|
|
654
|
+
TSDeclareFunction: checkFunction
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
|
|
551
659
|
const RULE_NAME$1 = "semi-spacing";
|
|
552
660
|
const semiSpacing = createEslintRule({
|
|
553
661
|
name: RULE_NAME$1,
|
|
@@ -654,7 +762,8 @@ const index = {
|
|
|
654
762
|
"space-in-empty-block": spaceInEmptyBlock,
|
|
655
763
|
"semi-spacing": semiSpacing,
|
|
656
764
|
"no-inline-type-import": noInlineTypeImport,
|
|
657
|
-
"no-spaces-before-paren": noSpacesBeforeParen
|
|
765
|
+
"no-spaces-before-paren": noSpacesBeforeParen,
|
|
766
|
+
"space-before-function-paren": spaceBeforeFunctionParen
|
|
658
767
|
}
|
|
659
768
|
};
|
|
660
769
|
|