@plugjs/eslint-plugin 0.2.22 → 0.2.24
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.
|
@@ -30,7 +30,7 @@ var require_package = __commonJS({
|
|
|
30
30
|
"node_modules/eslint-plugin-import-x/package.json"(exports2, module2) {
|
|
31
31
|
module2.exports = {
|
|
32
32
|
name: "eslint-plugin-import-x",
|
|
33
|
-
version: "4.
|
|
33
|
+
version: "4.4.0",
|
|
34
34
|
description: "Import with sanity.",
|
|
35
35
|
repository: "git+https://github.com/un-ts/eslint-plugin-import-x",
|
|
36
36
|
author: "JounQin <admin@1stg.me> (https://www.1stG.me)",
|
|
@@ -682,11 +682,11 @@ var require_parse = __commonJS({
|
|
|
682
682
|
return rest;
|
|
683
683
|
}
|
|
684
684
|
var log = (0, debug_1.default)("eslint-plugin-import-x:parse");
|
|
685
|
-
function keysFromParser(
|
|
685
|
+
function keysFromParser(_parserPath, parserInstance, parsedResult) {
|
|
686
686
|
if (parsedResult && parsedResult.visitorKeys) {
|
|
687
687
|
return parsedResult.visitorKeys;
|
|
688
688
|
}
|
|
689
|
-
if (
|
|
689
|
+
if (parserInstance && "VisitorKeys" in parserInstance && parserInstance.VisitorKeys) {
|
|
690
690
|
return parserInstance.VisitorKeys;
|
|
691
691
|
}
|
|
692
692
|
return null;
|
|
@@ -1207,7 +1207,9 @@ var require_export_map = __commonJS({
|
|
|
1207
1207
|
return null;
|
|
1208
1208
|
}
|
|
1209
1209
|
exportMap.mtime = stats().mtime.valueOf();
|
|
1210
|
-
|
|
1210
|
+
if (exportMap.visitorKeys) {
|
|
1211
|
+
exportCache.set(cacheKey, exportMap);
|
|
1212
|
+
}
|
|
1211
1213
|
return exportMap;
|
|
1212
1214
|
}
|
|
1213
1215
|
static get(source, context) {
|
|
@@ -2706,26 +2708,17 @@ var require_dynamic_import_chunkname = __commonJS({
|
|
|
2706
2708
|
var require_export = __commonJS({
|
|
2707
2709
|
"node_modules/eslint-plugin-import-x/lib/rules/export.js"(exports2, module2) {
|
|
2708
2710
|
"use strict";
|
|
2709
|
-
var utils_1 =
|
|
2711
|
+
var utils_1 = require("@typescript-eslint/utils");
|
|
2712
|
+
var utils_2 = require_utils();
|
|
2710
2713
|
var rootProgram = "root";
|
|
2711
2714
|
var tsTypePrefix = "type:";
|
|
2712
|
-
function
|
|
2713
|
-
const
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
const types = new Set(nodesArr.map((node) => `${node.parent.type}`));
|
|
2719
|
-
if (!types.has("TSDeclareFunction")) {
|
|
2720
|
-
return false;
|
|
2721
|
-
}
|
|
2722
|
-
if (types.size === 1) {
|
|
2723
|
-
return true;
|
|
2724
|
-
}
|
|
2725
|
-
if (types.size === 2 && types.has("FunctionDeclaration")) {
|
|
2726
|
-
return true;
|
|
2715
|
+
function removeTypescriptFunctionOverloads(nodes) {
|
|
2716
|
+
for (const node of nodes) {
|
|
2717
|
+
const declType = node.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration ? node.declaration.type : node.parent?.type;
|
|
2718
|
+
if (declType === utils_1.AST_NODE_TYPES.TSDeclareFunction) {
|
|
2719
|
+
nodes.delete(node);
|
|
2720
|
+
}
|
|
2727
2721
|
}
|
|
2728
|
-
return false;
|
|
2729
2722
|
}
|
|
2730
2723
|
function isTypescriptNamespaceMerging(nodes) {
|
|
2731
2724
|
const types = new Set(Array.from(nodes, (node) => `${node.parent.type}`));
|
|
@@ -2736,7 +2729,7 @@ var require_export = __commonJS({
|
|
|
2736
2729
|
const types = new Set(Array.from(nodes, (node2) => `${node2.parent.type}`));
|
|
2737
2730
|
return !isTypescriptNamespaceMerging(nodes) && node.parent.type === "TSModuleDeclaration" && (types.has("TSEnumDeclaration") || types.has("ClassDeclaration") || types.has("FunctionDeclaration") || types.has("TSDeclareFunction"));
|
|
2738
2731
|
}
|
|
2739
|
-
module2.exports = (0,
|
|
2732
|
+
module2.exports = (0, utils_2.createRule)({
|
|
2740
2733
|
name: "export",
|
|
2741
2734
|
meta: {
|
|
2742
2735
|
type: "problem",
|
|
@@ -2778,7 +2771,7 @@ var require_export = __commonJS({
|
|
|
2778
2771
|
addNamed("default", node, getParent(node));
|
|
2779
2772
|
},
|
|
2780
2773
|
ExportSpecifier(node) {
|
|
2781
|
-
addNamed((0,
|
|
2774
|
+
addNamed((0, utils_2.getValue)(node.exported), node.exported, getParent(node.parent));
|
|
2782
2775
|
},
|
|
2783
2776
|
ExportNamedDeclaration(node) {
|
|
2784
2777
|
if (node.declaration == null) {
|
|
@@ -2792,7 +2785,7 @@ var require_export = __commonJS({
|
|
|
2792
2785
|
}
|
|
2793
2786
|
if ("declarations" in node.declaration && node.declaration.declarations != null) {
|
|
2794
2787
|
for (const declaration of node.declaration.declarations) {
|
|
2795
|
-
(0,
|
|
2788
|
+
(0, utils_2.recursivePatternCapture)(declaration.id, (v) => {
|
|
2796
2789
|
addNamed(v.name, v, parent, isTypeVariableDecl);
|
|
2797
2790
|
});
|
|
2798
2791
|
}
|
|
@@ -2805,7 +2798,7 @@ var require_export = __commonJS({
|
|
|
2805
2798
|
if (node.exported && node.exported.name) {
|
|
2806
2799
|
return;
|
|
2807
2800
|
}
|
|
2808
|
-
const remoteExports =
|
|
2801
|
+
const remoteExports = utils_2.ExportMap.get(node.source.value, context);
|
|
2809
2802
|
if (remoteExports == null) {
|
|
2810
2803
|
return;
|
|
2811
2804
|
}
|
|
@@ -2832,10 +2825,14 @@ var require_export = __commonJS({
|
|
|
2832
2825
|
"Program:exit"() {
|
|
2833
2826
|
for (const [, named] of namespace) {
|
|
2834
2827
|
for (const [name, nodes] of named) {
|
|
2828
|
+
if (nodes.size === 0) {
|
|
2829
|
+
continue;
|
|
2830
|
+
}
|
|
2831
|
+
removeTypescriptFunctionOverloads(nodes);
|
|
2835
2832
|
if (nodes.size <= 1) {
|
|
2836
2833
|
continue;
|
|
2837
2834
|
}
|
|
2838
|
-
if (
|
|
2835
|
+
if (isTypescriptNamespaceMerging(nodes)) {
|
|
2839
2836
|
continue;
|
|
2840
2837
|
}
|
|
2841
2838
|
for (const node of nodes) {
|
|
@@ -2940,6 +2937,9 @@ var require_extensions = __commonJS({
|
|
|
2940
2937
|
pattern: patternProperties,
|
|
2941
2938
|
ignorePackages: {
|
|
2942
2939
|
type: "boolean"
|
|
2940
|
+
},
|
|
2941
|
+
checkTypeImports: {
|
|
2942
|
+
type: "boolean"
|
|
2943
2943
|
}
|
|
2944
2944
|
}
|
|
2945
2945
|
};
|
|
@@ -2947,14 +2947,15 @@ var require_extensions = __commonJS({
|
|
|
2947
2947
|
const result = {
|
|
2948
2948
|
defaultConfig: "never",
|
|
2949
2949
|
pattern: {},
|
|
2950
|
-
ignorePackages: false
|
|
2950
|
+
ignorePackages: false,
|
|
2951
|
+
checkTypeImports: false
|
|
2951
2952
|
};
|
|
2952
2953
|
for (const obj of context.options) {
|
|
2953
2954
|
if (typeof obj === "string") {
|
|
2954
2955
|
result.defaultConfig = obj;
|
|
2955
2956
|
continue;
|
|
2956
2957
|
}
|
|
2957
|
-
if (obj.pattern === void 0 && obj.ignorePackages === void 0) {
|
|
2958
|
+
if (obj.pattern === void 0 && obj.ignorePackages === void 0 && obj.checkTypeImports === void 0) {
|
|
2958
2959
|
Object.assign(result.pattern, obj);
|
|
2959
2960
|
continue;
|
|
2960
2961
|
}
|
|
@@ -2964,6 +2965,9 @@ var require_extensions = __commonJS({
|
|
|
2964
2965
|
if (obj.ignorePackages !== void 0) {
|
|
2965
2966
|
result.ignorePackages = obj.ignorePackages;
|
|
2966
2967
|
}
|
|
2968
|
+
if (obj.checkTypeImports !== void 0) {
|
|
2969
|
+
result.checkTypeImports = obj.checkTypeImports;
|
|
2970
|
+
}
|
|
2967
2971
|
}
|
|
2968
2972
|
if (result.defaultConfig === "ignorePackages") {
|
|
2969
2973
|
result.defaultConfig = "always";
|
|
@@ -3060,7 +3064,7 @@ var require_extensions = __commonJS({
|
|
|
3060
3064
|
const extension = node_path_1.default.extname(resolvedPath || importPath).slice(1);
|
|
3061
3065
|
const isPackage = (0, utils_1.isExternalModule)(importPath, (0, utils_1.resolve)(importPath, context), context) || (0, utils_1.isScoped)(importPath);
|
|
3062
3066
|
if (!extension || !importPath.endsWith(`.${extension}`)) {
|
|
3063
|
-
if ("importKind" in node && node.importKind === "type" || "exportKind" in node && node.exportKind === "type") {
|
|
3067
|
+
if (!props.checkTypeImports && ("importKind" in node && node.importKind === "type" || "exportKind" in node && node.exportKind === "type")) {
|
|
3064
3068
|
return;
|
|
3065
3069
|
}
|
|
3066
3070
|
const extensionRequired = isUseOfExtensionRequired(extension, isPackage);
|
|
@@ -4953,6 +4957,7 @@ var require_no_duplicates = __commonJS({
|
|
|
4953
4957
|
imported: /* @__PURE__ */ new Map(),
|
|
4954
4958
|
nsImported: /* @__PURE__ */ new Map(),
|
|
4955
4959
|
defaultTypesImported: /* @__PURE__ */ new Map(),
|
|
4960
|
+
namespaceTypesImported: /* @__PURE__ */ new Map(),
|
|
4956
4961
|
namedTypesImported: /* @__PURE__ */ new Map()
|
|
4957
4962
|
};
|
|
4958
4963
|
moduleMaps.set(parent, map);
|
|
@@ -4961,6 +4966,9 @@ var require_no_duplicates = __commonJS({
|
|
|
4961
4966
|
if (n.specifiers.length > 0 && n.specifiers[0].type === "ImportDefaultSpecifier") {
|
|
4962
4967
|
return map.defaultTypesImported;
|
|
4963
4968
|
}
|
|
4969
|
+
if (n.specifiers.length > 0 && n.specifiers[0].type === "ImportNamespaceSpecifier") {
|
|
4970
|
+
return map.namespaceTypesImported;
|
|
4971
|
+
}
|
|
4964
4972
|
if (!preferInline) {
|
|
4965
4973
|
return map.namedTypesImported;
|
|
4966
4974
|
}
|
|
@@ -5737,6 +5745,12 @@ var require_no_named_as_default = __commonJS({
|
|
|
5737
5745
|
exportMapOfImported.reportErrors(context, declaration);
|
|
5738
5746
|
return;
|
|
5739
5747
|
}
|
|
5748
|
+
if (!exportMapOfImported.hasDefault) {
|
|
5749
|
+
return;
|
|
5750
|
+
}
|
|
5751
|
+
if (!exportMapOfImported.has(nameValue)) {
|
|
5752
|
+
return;
|
|
5753
|
+
}
|
|
5740
5754
|
if (exportMapOfImported.exports.has("default") && exportMapOfImported.exports.has(nameValue)) {
|
|
5741
5755
|
context.report({
|
|
5742
5756
|
node: defaultSpecifier,
|
|
@@ -87,6 +87,7 @@ var require_utils = __commonJS({
|
|
|
87
87
|
case "Property":
|
|
88
88
|
case "PropertyDefinition":
|
|
89
89
|
case "MethodDefinition":
|
|
90
|
+
case "ImportAttribute":
|
|
90
91
|
prop = node.key;
|
|
91
92
|
break;
|
|
92
93
|
case "MemberExpression":
|
|
@@ -2505,7 +2506,7 @@ var require_comma_spacing = __commonJS({
|
|
|
2505
2506
|
}
|
|
2506
2507
|
}
|
|
2507
2508
|
function validateCommaSpacing(commaToken, prevToken, nextToken) {
|
|
2508
|
-
if (prevToken && astUtils.isTokenOnSameLine(prevToken, commaToken) && spaceBefore !== sourceCode.
|
|
2509
|
+
if (prevToken && astUtils.isTokenOnSameLine(prevToken, commaToken) && spaceBefore !== sourceCode.isSpaceBetween(prevToken, commaToken)) {
|
|
2509
2510
|
context.report({
|
|
2510
2511
|
node: commaToken,
|
|
2511
2512
|
data: {
|
|
@@ -2518,14 +2519,7 @@ var require_comma_spacing = __commonJS({
|
|
|
2518
2519
|
)
|
|
2519
2520
|
});
|
|
2520
2521
|
}
|
|
2521
|
-
if (nextToken && astUtils.isClosingParenToken(nextToken))
|
|
2522
|
-
return;
|
|
2523
|
-
if (spaceAfter && nextToken && (astUtils.isClosingBraceToken(nextToken) || astUtils.isClosingBracketToken(nextToken))) {
|
|
2524
|
-
return;
|
|
2525
|
-
}
|
|
2526
|
-
if (!spaceAfter && nextToken && nextToken.type === utils$1.AST_TOKEN_TYPES.Line)
|
|
2527
|
-
return;
|
|
2528
|
-
if (nextToken && astUtils.isTokenOnSameLine(commaToken, nextToken) && spaceAfter !== sourceCode.isSpaceBetweenTokens(commaToken, nextToken)) {
|
|
2522
|
+
if (nextToken && astUtils.isTokenOnSameLine(commaToken, nextToken) && !astUtils.isClosingParenToken(nextToken) && !astUtils.isClosingBracketToken(nextToken) && !astUtils.isClosingBraceToken(nextToken) && !(!spaceAfter && nextToken.type === utils$1.AST_TOKEN_TYPES.Line) && spaceAfter !== sourceCode.isSpaceBetween(commaToken, nextToken)) {
|
|
2529
2523
|
context.report({
|
|
2530
2524
|
node: commaToken,
|
|
2531
2525
|
data: {
|
|
@@ -3507,38 +3501,30 @@ var require_function_call_spacing = __commonJS({
|
|
|
3507
3501
|
create(context, [option, config]) {
|
|
3508
3502
|
const sourceCode = context.sourceCode;
|
|
3509
3503
|
const text = sourceCode.getText();
|
|
3510
|
-
function checkSpacing(node) {
|
|
3504
|
+
function checkSpacing(node, leftToken, rightToken) {
|
|
3511
3505
|
const isOptionalCall = astUtils.isOptionalCallExpression(node);
|
|
3512
|
-
const
|
|
3513
|
-
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken(
|
|
3514
|
-
node.typeArguments ?? node.callee
|
|
3515
|
-
);
|
|
3516
|
-
const openingParenToken = sourceCode.getFirstTokenBetween(
|
|
3517
|
-
lastCalleeTokenWithoutPossibleParens,
|
|
3518
|
-
closingParenToken,
|
|
3519
|
-
astUtils.isOpeningParenToken
|
|
3520
|
-
);
|
|
3521
|
-
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {
|
|
3522
|
-
return;
|
|
3523
|
-
}
|
|
3524
|
-
const lastCalleeToken = sourceCode.getTokenBefore(
|
|
3525
|
-
openingParenToken,
|
|
3526
|
-
astUtils.isNotOptionalChainPunctuator
|
|
3527
|
-
);
|
|
3528
|
-
const textBetweenTokens = text.slice(lastCalleeToken.range[1], openingParenToken.range[0]).replace(/\/\*.*?\*\//gu, "");
|
|
3506
|
+
const textBetweenTokens = text.slice(leftToken.range[1], rightToken.range[0]).replace(/\/\*.*?\*\//gu, "");
|
|
3529
3507
|
const hasWhitespace = /\s/u.test(textBetweenTokens);
|
|
3530
3508
|
const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
|
|
3531
3509
|
if (option === "never") {
|
|
3532
3510
|
if (hasWhitespace) {
|
|
3533
3511
|
return context.report({
|
|
3534
3512
|
node,
|
|
3535
|
-
loc:
|
|
3513
|
+
loc: leftToken.loc.start,
|
|
3536
3514
|
messageId: "unexpectedWhitespace",
|
|
3537
3515
|
fix(fixer) {
|
|
3538
|
-
if (
|
|
3516
|
+
if (sourceCode.commentsExistBetween(leftToken, rightToken))
|
|
3517
|
+
return null;
|
|
3518
|
+
if (isOptionalCall) {
|
|
3519
|
+
return fixer.replaceTextRange([
|
|
3520
|
+
leftToken.range[1],
|
|
3521
|
+
rightToken.range[0]
|
|
3522
|
+
], "?.");
|
|
3523
|
+
}
|
|
3524
|
+
if (!hasNewline) {
|
|
3539
3525
|
return fixer.removeRange([
|
|
3540
|
-
|
|
3541
|
-
|
|
3526
|
+
leftToken.range[1],
|
|
3527
|
+
rightToken.range[0]
|
|
3542
3528
|
]);
|
|
3543
3529
|
}
|
|
3544
3530
|
return null;
|
|
@@ -3549,7 +3535,7 @@ var require_function_call_spacing = __commonJS({
|
|
|
3549
3535
|
if (hasWhitespace || hasNewline) {
|
|
3550
3536
|
context.report({
|
|
3551
3537
|
node,
|
|
3552
|
-
loc:
|
|
3538
|
+
loc: leftToken.loc.start,
|
|
3553
3539
|
messageId: "unexpectedWhitespace"
|
|
3554
3540
|
});
|
|
3555
3541
|
}
|
|
@@ -3557,20 +3543,22 @@ var require_function_call_spacing = __commonJS({
|
|
|
3557
3543
|
if (!hasWhitespace) {
|
|
3558
3544
|
context.report({
|
|
3559
3545
|
node,
|
|
3560
|
-
loc:
|
|
3546
|
+
loc: leftToken.loc.start,
|
|
3561
3547
|
messageId: "missing",
|
|
3562
3548
|
fix(fixer) {
|
|
3563
|
-
return fixer.insertTextBefore(
|
|
3549
|
+
return fixer.insertTextBefore(rightToken, " ");
|
|
3564
3550
|
}
|
|
3565
3551
|
});
|
|
3566
3552
|
} else if (!config.allowNewlines && hasNewline) {
|
|
3567
3553
|
context.report({
|
|
3568
3554
|
node,
|
|
3569
|
-
loc:
|
|
3555
|
+
loc: leftToken.loc.start,
|
|
3570
3556
|
messageId: "unexpectedNewline",
|
|
3571
3557
|
fix(fixer) {
|
|
3558
|
+
if (sourceCode.commentsExistBetween(leftToken, rightToken))
|
|
3559
|
+
return null;
|
|
3572
3560
|
return fixer.replaceTextRange(
|
|
3573
|
-
[
|
|
3561
|
+
[leftToken.range[1], rightToken.range[0]],
|
|
3574
3562
|
" "
|
|
3575
3563
|
);
|
|
3576
3564
|
}
|
|
@@ -3579,8 +3567,30 @@ var require_function_call_spacing = __commonJS({
|
|
|
3579
3567
|
}
|
|
3580
3568
|
}
|
|
3581
3569
|
return {
|
|
3582
|
-
CallExpression:
|
|
3583
|
-
|
|
3570
|
+
"CallExpression, NewExpression": function(node) {
|
|
3571
|
+
const closingParenToken = sourceCode.getLastToken(node);
|
|
3572
|
+
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken(
|
|
3573
|
+
node.typeArguments ?? node.callee
|
|
3574
|
+
);
|
|
3575
|
+
const openingParenToken = sourceCode.getFirstTokenBetween(
|
|
3576
|
+
lastCalleeTokenWithoutPossibleParens,
|
|
3577
|
+
closingParenToken,
|
|
3578
|
+
astUtils.isOpeningParenToken
|
|
3579
|
+
);
|
|
3580
|
+
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3583
|
+
const lastCalleeToken = sourceCode.getTokenBefore(
|
|
3584
|
+
openingParenToken,
|
|
3585
|
+
astUtils.isNotOptionalChainPunctuator
|
|
3586
|
+
);
|
|
3587
|
+
checkSpacing(node, lastCalleeToken, openingParenToken);
|
|
3588
|
+
},
|
|
3589
|
+
ImportExpression(node) {
|
|
3590
|
+
const leftToken = sourceCode.getFirstToken(node);
|
|
3591
|
+
const rightToken = sourceCode.getTokenAfter(leftToken);
|
|
3592
|
+
checkSpacing(node, leftToken, rightToken);
|
|
3593
|
+
}
|
|
3584
3594
|
};
|
|
3585
3595
|
}
|
|
3586
3596
|
});
|
|
@@ -4089,7 +4099,8 @@ var require_indent = __commonJS({
|
|
|
4089
4099
|
"ImportSpecifier",
|
|
4090
4100
|
"ImportDefaultSpecifier",
|
|
4091
4101
|
"ImportNamespaceSpecifier",
|
|
4092
|
-
"ImportExpression"
|
|
4102
|
+
"ImportExpression",
|
|
4103
|
+
"ImportAttribute"
|
|
4093
4104
|
]);
|
|
4094
4105
|
var IndexMap = class {
|
|
4095
4106
|
/**
|
|
@@ -4842,13 +4853,38 @@ var require_indent = __commonJS({
|
|
|
4842
4853
|
},
|
|
4843
4854
|
ExportNamedDeclaration(node) {
|
|
4844
4855
|
if (node.declaration === null) {
|
|
4845
|
-
const closingCurly = sourceCode.getLastToken(node, utils.isClosingBraceToken);
|
|
4856
|
+
const closingCurly = node.source ? sourceCode.getTokenBefore(node.source, utils.isClosingBraceToken) : sourceCode.getLastToken(node, utils.isClosingBraceToken);
|
|
4846
4857
|
addElementListIndent(node.specifiers, sourceCode.getFirstToken(node, { skip: 1 }), closingCurly, 1);
|
|
4847
4858
|
if (node.source) {
|
|
4848
|
-
|
|
4859
|
+
const fromToken = sourceCode.getTokenAfter(
|
|
4860
|
+
closingCurly,
|
|
4861
|
+
(token) => token.type === "Identifier" && token.value === "from"
|
|
4862
|
+
);
|
|
4863
|
+
const lastToken = sourceCode.getLastToken(node, utils.isNotSemicolonToken);
|
|
4864
|
+
offsets.setDesiredOffsets([fromToken.range[0], lastToken.range[1]], sourceCode.getFirstToken(node), 1);
|
|
4865
|
+
const lastClosingCurly = sourceCode.getLastToken(node, utils.isClosingBraceToken);
|
|
4866
|
+
if (lastClosingCurly && node.source.range[1] < lastClosingCurly.range[0]) {
|
|
4867
|
+
const openingCurly = sourceCode.getTokenAfter(node.source, utils.isOpeningBraceToken);
|
|
4868
|
+
const closingCurly2 = lastClosingCurly;
|
|
4869
|
+
addElementListIndent(node.attributes, openingCurly, closingCurly2, 1);
|
|
4870
|
+
}
|
|
4849
4871
|
}
|
|
4850
4872
|
}
|
|
4851
4873
|
},
|
|
4874
|
+
ExportAllDeclaration(node) {
|
|
4875
|
+
const fromToken = sourceCode.getTokenAfter(
|
|
4876
|
+
node.exported || sourceCode.getFirstToken(node),
|
|
4877
|
+
(token) => token.type === "Identifier" && token.value === "from"
|
|
4878
|
+
);
|
|
4879
|
+
const lastToken = sourceCode.getLastToken(node, utils.isNotSemicolonToken);
|
|
4880
|
+
offsets.setDesiredOffsets([fromToken.range[0], lastToken.range[1]], sourceCode.getFirstToken(node), 1);
|
|
4881
|
+
const lastClosingCurly = sourceCode.getLastToken(node, utils.isClosingBraceToken);
|
|
4882
|
+
if (lastClosingCurly && node.source.range[1] < lastClosingCurly.range[0]) {
|
|
4883
|
+
const openingCurly = sourceCode.getTokenAfter(node.source, utils.isOpeningBraceToken);
|
|
4884
|
+
const closingCurly = lastClosingCurly;
|
|
4885
|
+
addElementListIndent(node.attributes, openingCurly, closingCurly, 1);
|
|
4886
|
+
}
|
|
4887
|
+
},
|
|
4852
4888
|
ForStatement(node) {
|
|
4853
4889
|
const forOpeningParen = sourceCode.getFirstToken(node, 1);
|
|
4854
4890
|
if (node.init)
|
|
@@ -4912,15 +4948,23 @@ var require_indent = __commonJS({
|
|
|
4912
4948
|
ImportDeclaration(node) {
|
|
4913
4949
|
if (node.specifiers.some((specifier) => specifier.type === "ImportSpecifier")) {
|
|
4914
4950
|
const openingCurly = sourceCode.getFirstToken(node, utils.isOpeningBraceToken);
|
|
4915
|
-
const closingCurly = sourceCode.
|
|
4951
|
+
const closingCurly = sourceCode.getTokenBefore(node.source, utils.isClosingBraceToken);
|
|
4916
4952
|
addElementListIndent(node.specifiers.filter((specifier) => specifier.type === "ImportSpecifier"), openingCurly, closingCurly, options.ImportDeclaration);
|
|
4917
4953
|
}
|
|
4918
|
-
const fromToken = sourceCode.
|
|
4919
|
-
const
|
|
4920
|
-
const semiToken = sourceCode.getLastToken(node, (token) => token.type === "Punctuator" && token.value === ";");
|
|
4954
|
+
const fromToken = node.specifiers.length ? sourceCode.getTokenAfter(node.specifiers[node.specifiers.length - 1], (token) => token.type === "Identifier" && token.value === "from") : sourceCode.getFirstToken(node, (token) => token.type === "Identifier" && token.value === "from");
|
|
4955
|
+
const lastToken = sourceCode.getLastToken(node, utils.isNotSemicolonToken);
|
|
4921
4956
|
if (fromToken) {
|
|
4922
|
-
|
|
4923
|
-
|
|
4957
|
+
offsets.setDesiredOffsets([fromToken.range[0], lastToken.range[1]], sourceCode.getFirstToken(node), 1);
|
|
4958
|
+
}
|
|
4959
|
+
const lastClosingCurly = sourceCode.getLastToken(node, utils.isClosingBraceToken);
|
|
4960
|
+
if (lastClosingCurly && node.source.range[1] < lastClosingCurly.range[0]) {
|
|
4961
|
+
const openingCurly = sourceCode.getTokenAfter(node.source, utils.isOpeningBraceToken);
|
|
4962
|
+
const closingCurly = lastClosingCurly;
|
|
4963
|
+
if (!fromToken) {
|
|
4964
|
+
const withToken = sourceCode.getTokenBefore(openingCurly, (token) => token.value === "with");
|
|
4965
|
+
offsets.setDesiredOffsets([withToken.range[0], lastToken.range[1]], sourceCode.getFirstToken(node), 1);
|
|
4966
|
+
}
|
|
4967
|
+
addElementListIndent(node.attributes, openingCurly, closingCurly, 1);
|
|
4924
4968
|
}
|
|
4925
4969
|
},
|
|
4926
4970
|
ImportExpression(node) {
|
|
@@ -5722,12 +5766,44 @@ var require_indent_binary_ops = __commonJS({
|
|
|
5722
5766
|
return indentCache.get(line);
|
|
5723
5767
|
return sourceCode.lines[line - 1].match(/^\s*/)?.[0] ?? "";
|
|
5724
5768
|
}
|
|
5769
|
+
function subtractionIndent(indent) {
|
|
5770
|
+
if (options[0] === "tab") {
|
|
5771
|
+
return indent.slice(1);
|
|
5772
|
+
}
|
|
5773
|
+
return indent.slice(options[0] ?? 2);
|
|
5774
|
+
}
|
|
5775
|
+
function getTargetIndent(indent, needAdditionIndent, needSubtractionIndent) {
|
|
5776
|
+
if (needAdditionIndent && !needSubtractionIndent) {
|
|
5777
|
+
return indent + indentStr;
|
|
5778
|
+
}
|
|
5779
|
+
if (!needAdditionIndent && needSubtractionIndent) {
|
|
5780
|
+
return subtractionIndent(indent);
|
|
5781
|
+
}
|
|
5782
|
+
return indent;
|
|
5783
|
+
}
|
|
5725
5784
|
function firstTokenOfLine(line) {
|
|
5726
5785
|
return sourceCode.tokensAndComments.find((token) => token.loc.start.line === line);
|
|
5727
5786
|
}
|
|
5728
5787
|
function lastTokenOfLine(line) {
|
|
5729
5788
|
return [...sourceCode.tokensAndComments].reverse().find((token) => token.loc.end.line === line);
|
|
5730
5789
|
}
|
|
5790
|
+
function isGreaterThanCloseBracketOfLine(line) {
|
|
5791
|
+
const tokensAndCommentsOfLine = sourceCode.tokensAndComments.filter((token) => token.loc.start.line === line);
|
|
5792
|
+
let openBracketCount = 0;
|
|
5793
|
+
let closeBracketCount = 0;
|
|
5794
|
+
for (const token of tokensAndCommentsOfLine) {
|
|
5795
|
+
if (token.value === "(") {
|
|
5796
|
+
openBracketCount++;
|
|
5797
|
+
}
|
|
5798
|
+
if (token.value === ")") {
|
|
5799
|
+
closeBracketCount++;
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
return openBracketCount < closeBracketCount;
|
|
5803
|
+
}
|
|
5804
|
+
function hasExclusivelyCloseBracketOfLine(line) {
|
|
5805
|
+
return !sourceCode.tokensAndComments.some((token) => token.loc.start.line === line && ![")", "}", "]"].includes(token.value));
|
|
5806
|
+
}
|
|
5731
5807
|
function handler(node, right) {
|
|
5732
5808
|
if (node.loc.start.line === node.loc.end.line)
|
|
5733
5809
|
return;
|
|
@@ -5747,8 +5823,10 @@ var require_indent_binary_ops = __commonJS({
|
|
|
5747
5823
|
const firstTokenOfLineLeft = firstTokenOfLine(tokenLeft.loc.start.line);
|
|
5748
5824
|
const lastTokenOfLineLeft = lastTokenOfLine(tokenLeft.loc.start.line);
|
|
5749
5825
|
const needAdditionIndent = firstTokenOfLineLeft?.type === "Keyword" && !["typeof", "instanceof", "this"].includes(firstTokenOfLineLeft.value) || firstTokenOfLineLeft?.type === "Identifier" && firstTokenOfLineLeft.value === "type" && node.parent?.type === "TSTypeAliasDeclaration" || [":", "[", "(", "<", "="].includes(lastTokenOfLineLeft?.value || "") || ["[", "(", "=>", ":"].includes(tokenBeforeAll?.value || "") && firstTokenOfLineLeft?.loc.start.line === tokenBeforeAll?.loc.start.line || ["||", "&&"].includes(lastTokenOfLineLeft?.value || "") && node.loc.start.line === tokenLeft.loc.start.line && node.loc.start.column !== getIndentOfLine(node.loc.start.line).length;
|
|
5750
|
-
const
|
|
5826
|
+
const needSubtractionIndent = lastTokenOfLineLeft?.value === ")" && isGreaterThanCloseBracketOfLine(tokenLeft.loc.start.line) && !hasExclusivelyCloseBracketOfLine(tokenLeft.loc.start.line);
|
|
5827
|
+
const indentLeft = getIndentOfLine(tokenLeft.loc.start.line);
|
|
5751
5828
|
const indentRight = getIndentOfLine(tokenRight.loc.start.line);
|
|
5829
|
+
const indentTarget = getTargetIndent(indentLeft, needAdditionIndent, needSubtractionIndent);
|
|
5752
5830
|
if (indentTarget !== indentRight) {
|
|
5753
5831
|
const start = {
|
|
5754
5832
|
line: tokenRight.loc.start.line,
|
|
@@ -6093,26 +6171,21 @@ var require_jsx_closing_bracket_location = __commonJS({
|
|
|
6093
6171
|
openingStartOfLine
|
|
6094
6172
|
};
|
|
6095
6173
|
}
|
|
6096
|
-
function getOpeningElementId(node) {
|
|
6097
|
-
return node.range.join(":");
|
|
6098
|
-
}
|
|
6099
|
-
const lastAttributeNode = {};
|
|
6100
6174
|
return {
|
|
6101
|
-
JSXAttribute(node) {
|
|
6102
|
-
lastAttributeNode[getOpeningElementId(node.parent)] = node;
|
|
6103
|
-
},
|
|
6104
|
-
JSXSpreadAttribute(node) {
|
|
6105
|
-
lastAttributeNode[getOpeningElementId(node.parent)] = node;
|
|
6106
|
-
},
|
|
6107
6175
|
"JSXOpeningElement:exit": function(node) {
|
|
6108
|
-
const
|
|
6109
|
-
const cachedLastAttributeEndPos =
|
|
6176
|
+
const lastAttributeNode = node.attributes.at(-1);
|
|
6177
|
+
const cachedLastAttributeEndPos = lastAttributeNode ? lastAttributeNode.range[1] : null;
|
|
6110
6178
|
let expectedNextLine;
|
|
6111
6179
|
const tokens = getTokensLocations(node);
|
|
6112
|
-
|
|
6180
|
+
let expectedLocation = getExpectedLocation(tokens);
|
|
6113
6181
|
let usingSameIndentation = true;
|
|
6114
6182
|
if (expectedLocation === "tag-aligned")
|
|
6115
6183
|
usingSameIndentation = tokens.isTab.openTab === tokens.isTab.closeTab;
|
|
6184
|
+
const lastComment = context.sourceCode.getCommentsInside(node).at(-1);
|
|
6185
|
+
const hasTrailingComment = lastComment && lastComment.range[0] > (lastAttributeNode ?? node.name).range[1];
|
|
6186
|
+
if ((expectedLocation === "after-props" || expectedLocation === "after-tag") && !(hasCorrectLocation(tokens, expectedLocation) && usingSameIndentation) && hasTrailingComment) {
|
|
6187
|
+
expectedLocation = "line-aligned";
|
|
6188
|
+
}
|
|
6116
6189
|
if (hasCorrectLocation(tokens, expectedLocation) && usingSameIndentation)
|
|
6117
6190
|
return;
|
|
6118
6191
|
const data = {
|
|
@@ -6140,9 +6213,11 @@ var require_jsx_closing_bracket_location = __commonJS({
|
|
|
6140
6213
|
return fixer.replaceTextRange([cachedLastAttributeEndPos, node.range[1]], (expectedNextLine ? "\n" : "") + closingTag);
|
|
6141
6214
|
case "props-aligned":
|
|
6142
6215
|
case "tag-aligned":
|
|
6143
|
-
case "line-aligned":
|
|
6144
|
-
|
|
6216
|
+
case "line-aligned": {
|
|
6217
|
+
const rangeStart = hasTrailingComment ? lastComment.range[1] : cachedLastAttributeEndPos;
|
|
6218
|
+
return fixer.replaceTextRange([rangeStart, node.range[1]], `
|
|
6145
6219
|
${getIndentation(tokens, expectedLocation, correctColumn)}${closingTag}`);
|
|
6220
|
+
}
|
|
6146
6221
|
}
|
|
6147
6222
|
return null;
|
|
6148
6223
|
}
|
|
@@ -9412,6 +9487,11 @@ var require_key_spacing = __commonJS({
|
|
|
9412
9487
|
function isSingleLine(node) {
|
|
9413
9488
|
return node.loc.end.line === node.loc.start.line;
|
|
9414
9489
|
}
|
|
9490
|
+
function isSingleLineImportAttributes(node, sourceCode) {
|
|
9491
|
+
const openingBrace = sourceCode.getTokenBefore(node.attributes[0], utils.isOpeningBraceToken);
|
|
9492
|
+
const closingBrace = sourceCode.getTokenAfter(node.attributes[node.attributes.length - 1], utils.isClosingBraceToken);
|
|
9493
|
+
return closingBrace.loc.end.line === openingBrace.loc.start.line;
|
|
9494
|
+
}
|
|
9415
9495
|
function isSingleLineProperties(properties) {
|
|
9416
9496
|
const [firstProp] = properties;
|
|
9417
9497
|
const lastProp = last(properties);
|
|
@@ -9658,6 +9738,8 @@ var require_key_spacing = __commonJS({
|
|
|
9658
9738
|
const alignmentOptions = ruleOptions.align || null;
|
|
9659
9739
|
const sourceCode = context.sourceCode;
|
|
9660
9740
|
function isKeyValueProperty(property) {
|
|
9741
|
+
if (property.type === "ImportAttribute")
|
|
9742
|
+
return true;
|
|
9661
9743
|
return !("method" in property && property.method || "shorthand" in property && property.shorthand || "kind" in property && property.kind !== "init" || property.type !== "Property");
|
|
9662
9744
|
}
|
|
9663
9745
|
function getNextColon(node) {
|
|
@@ -9688,7 +9770,7 @@ var require_key_spacing = __commonJS({
|
|
|
9688
9770
|
}
|
|
9689
9771
|
function getKey(property) {
|
|
9690
9772
|
const key = property.key;
|
|
9691
|
-
if (property.computed)
|
|
9773
|
+
if (property.type !== "ImportAttribute" && property.computed)
|
|
9692
9774
|
return sourceCode.getText().slice(key.range[0], key.range[1]);
|
|
9693
9775
|
return utils.getStaticPropertyName(property);
|
|
9694
9776
|
}
|
|
@@ -9737,7 +9819,7 @@ var require_key_spacing = __commonJS({
|
|
|
9737
9819
|
loc,
|
|
9738
9820
|
messageId,
|
|
9739
9821
|
data: {
|
|
9740
|
-
computed: property.computed ? "computed " : "",
|
|
9822
|
+
computed: property.type !== "ImportAttribute" && property.computed ? "computed " : "",
|
|
9741
9823
|
key: getKey(property)
|
|
9742
9824
|
},
|
|
9743
9825
|
fix
|
|
@@ -9762,10 +9844,10 @@ var require_key_spacing = __commonJS({
|
|
|
9762
9844
|
}
|
|
9763
9845
|
return null;
|
|
9764
9846
|
}
|
|
9765
|
-
function createGroups(
|
|
9766
|
-
if (
|
|
9767
|
-
return [
|
|
9768
|
-
return
|
|
9847
|
+
function createGroups(properties) {
|
|
9848
|
+
if (properties.length === 1)
|
|
9849
|
+
return [properties];
|
|
9850
|
+
return properties.reduce((groups, property) => {
|
|
9769
9851
|
const currentGroup = last(groups);
|
|
9770
9852
|
const prev = last(currentGroup);
|
|
9771
9853
|
if (!prev || continuesPropertyGroup(prev, property))
|
|
@@ -9822,39 +9904,55 @@ var require_key_spacing = __commonJS({
|
|
|
9822
9904
|
for (let i = 0; i < length; i++)
|
|
9823
9905
|
verifySpacing(properties[i], lineOptions);
|
|
9824
9906
|
}
|
|
9825
|
-
function verifyAlignment(
|
|
9826
|
-
createGroups(
|
|
9827
|
-
const
|
|
9828
|
-
if (
|
|
9829
|
-
verifyListSpacing(
|
|
9907
|
+
function verifyAlignment(properties) {
|
|
9908
|
+
createGroups(properties).forEach((group) => {
|
|
9909
|
+
const properties2 = group.filter(isKeyValueProperty);
|
|
9910
|
+
if (properties2.length > 0 && isSingleLineProperties(properties2))
|
|
9911
|
+
verifyListSpacing(properties2, multiLineOptions);
|
|
9830
9912
|
else
|
|
9831
|
-
verifyGroupAlignment(
|
|
9913
|
+
verifyGroupAlignment(properties2);
|
|
9832
9914
|
});
|
|
9833
9915
|
}
|
|
9916
|
+
function verifyImportAttributes(node) {
|
|
9917
|
+
if (!node.attributes)
|
|
9918
|
+
return;
|
|
9919
|
+
if (isSingleLineImportAttributes(node, sourceCode))
|
|
9920
|
+
verifyListSpacing(node.attributes, singleLineOptions);
|
|
9921
|
+
else
|
|
9922
|
+
verifyAlignment(node.attributes);
|
|
9923
|
+
}
|
|
9834
9924
|
if (alignmentOptions) {
|
|
9835
9925
|
return {
|
|
9836
9926
|
ObjectExpression(node) {
|
|
9837
9927
|
if (isSingleLine(node))
|
|
9838
9928
|
verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions);
|
|
9839
9929
|
else
|
|
9840
|
-
verifyAlignment(node);
|
|
9930
|
+
verifyAlignment(node.properties);
|
|
9931
|
+
},
|
|
9932
|
+
ImportDeclaration(node) {
|
|
9933
|
+
verifyImportAttributes(node);
|
|
9934
|
+
},
|
|
9935
|
+
ExportNamedDeclaration(node) {
|
|
9936
|
+
verifyImportAttributes(node);
|
|
9937
|
+
},
|
|
9938
|
+
ExportAllDeclaration(node) {
|
|
9939
|
+
verifyImportAttributes(node);
|
|
9841
9940
|
}
|
|
9842
9941
|
};
|
|
9843
9942
|
}
|
|
9844
9943
|
return {
|
|
9845
9944
|
Property(node) {
|
|
9846
9945
|
verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
|
|
9946
|
+
},
|
|
9947
|
+
ImportAttribute(node) {
|
|
9948
|
+
const parent = node.parent;
|
|
9949
|
+
verifySpacing(node, isSingleLineImportAttributes(parent, sourceCode) ? singleLineOptions : multiLineOptions);
|
|
9847
9950
|
}
|
|
9848
9951
|
};
|
|
9849
9952
|
}
|
|
9850
9953
|
});
|
|
9851
9954
|
var baseRule = /* @__PURE__ */ utils.castRuleModule(_baseRule);
|
|
9852
9955
|
var baseSchema = Array.isArray(baseRule.meta.schema) ? baseRule.meta.schema[0] : baseRule.meta.schema;
|
|
9853
|
-
function at(arr, position) {
|
|
9854
|
-
if (position < 0)
|
|
9855
|
-
return arr[arr.length + position];
|
|
9856
|
-
return arr[position];
|
|
9857
|
-
}
|
|
9858
9956
|
var keySpacing = utils.createRule({
|
|
9859
9957
|
name: "key-spacing",
|
|
9860
9958
|
package: "ts",
|
|
@@ -9876,7 +9974,7 @@ var require_key_spacing = __commonJS({
|
|
|
9876
9974
|
function adjustedColumn(position) {
|
|
9877
9975
|
const line = position.line - 1;
|
|
9878
9976
|
return utils.getStringLength(
|
|
9879
|
-
|
|
9977
|
+
sourceCode.lines.at(line).slice(0, position.column)
|
|
9880
9978
|
);
|
|
9881
9979
|
}
|
|
9882
9980
|
function getLastTokenBeforeColon(node) {
|
|
@@ -9896,14 +9994,14 @@ var require_key_spacing = __commonJS({
|
|
|
9896
9994
|
return code.slice(
|
|
9897
9995
|
0,
|
|
9898
9996
|
sourceCode.getTokenAfter(
|
|
9899
|
-
|
|
9997
|
+
node.parameters.at(-1),
|
|
9900
9998
|
astUtils.isClosingBracketToken
|
|
9901
9999
|
).range[1] - node.range[0]
|
|
9902
10000
|
);
|
|
9903
10001
|
}
|
|
9904
10002
|
function getKeyLocEnd(node) {
|
|
9905
10003
|
return getLastTokenBeforeColon(
|
|
9906
|
-
node.type !== utils$1.AST_NODE_TYPES.TSIndexSignature ? node.key :
|
|
10004
|
+
node.type !== utils$1.AST_NODE_TYPES.TSIndexSignature ? node.key : node.parameters.at(-1)
|
|
9907
10005
|
).loc.end;
|
|
9908
10006
|
}
|
|
9909
10007
|
function checkBeforeColon(node, expectedWhitespaceBeforeColon, mode) {
|
|
@@ -9969,7 +10067,7 @@ var require_key_spacing = __commonJS({
|
|
|
9969
10067
|
if (candidateValueStartLine - groupEndLine === 1)
|
|
9970
10068
|
return true;
|
|
9971
10069
|
const leadingComments = sourceCode.getCommentsBefore(candidate);
|
|
9972
|
-
if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - at(
|
|
10070
|
+
if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - leadingComments.at(-1).loc.end.line <= 1) {
|
|
9973
10071
|
for (let i = 1; i < leadingComments.length; i++) {
|
|
9974
10072
|
if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
|
|
9975
10073
|
return false;
|
|
@@ -10048,7 +10146,7 @@ var require_key_spacing = __commonJS({
|
|
|
10048
10146
|
alignGroups.push(currentAlignGroup);
|
|
10049
10147
|
let prevNode;
|
|
10050
10148
|
for (const node of members) {
|
|
10051
|
-
let prevAlignedNode = at(
|
|
10149
|
+
let prevAlignedNode = currentAlignGroup.at(-1);
|
|
10052
10150
|
if (prevAlignedNode !== prevNode)
|
|
10053
10151
|
prevAlignedNode = void 0;
|
|
10054
10152
|
if (prevAlignedNode && continuesAlignGroup(prevAlignedNode, node)) {
|
|
@@ -11716,6 +11814,31 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11716
11814
|
require("eslint-visitor-keys");
|
|
11717
11815
|
require("espree");
|
|
11718
11816
|
require("estraverse");
|
|
11817
|
+
var listeningNodes = [
|
|
11818
|
+
"BreakStatement",
|
|
11819
|
+
"ClassDeclaration",
|
|
11820
|
+
"ContinueStatement",
|
|
11821
|
+
"DebuggerStatement",
|
|
11822
|
+
"DoWhileStatement",
|
|
11823
|
+
"ExpressionStatement",
|
|
11824
|
+
"ForInStatement",
|
|
11825
|
+
"ForOfStatement",
|
|
11826
|
+
"ForStatement",
|
|
11827
|
+
"FunctionDeclaration",
|
|
11828
|
+
"IfStatement",
|
|
11829
|
+
"ImportDeclaration",
|
|
11830
|
+
"LabeledStatement",
|
|
11831
|
+
"ReturnStatement",
|
|
11832
|
+
"SwitchStatement",
|
|
11833
|
+
"ThrowStatement",
|
|
11834
|
+
"TryStatement",
|
|
11835
|
+
"VariableDeclaration",
|
|
11836
|
+
"WhileStatement",
|
|
11837
|
+
"WithStatement",
|
|
11838
|
+
"ExportNamedDeclaration",
|
|
11839
|
+
"ExportDefaultDeclaration",
|
|
11840
|
+
"ExportAllDeclaration"
|
|
11841
|
+
];
|
|
11719
11842
|
var maxStatementsPerLine = utils.createRule({
|
|
11720
11843
|
name: "max-statements-per-line",
|
|
11721
11844
|
package: "js",
|
|
@@ -11732,6 +11855,13 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11732
11855
|
type: "integer",
|
|
11733
11856
|
minimum: 1,
|
|
11734
11857
|
default: 1
|
|
11858
|
+
},
|
|
11859
|
+
ignoredNodes: {
|
|
11860
|
+
type: "array",
|
|
11861
|
+
items: {
|
|
11862
|
+
type: "string",
|
|
11863
|
+
enum: listeningNodes
|
|
11864
|
+
}
|
|
11735
11865
|
}
|
|
11736
11866
|
},
|
|
11737
11867
|
additionalProperties: false
|
|
@@ -11745,6 +11875,7 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11745
11875
|
const sourceCode = context.sourceCode;
|
|
11746
11876
|
const options = context.options[0] || {};
|
|
11747
11877
|
const maxStatementsPerLine2 = typeof options.max !== "undefined" ? options.max : 1;
|
|
11878
|
+
const ignoredNodes = options.ignoredNodes || [];
|
|
11748
11879
|
let lastStatementLine = 0;
|
|
11749
11880
|
let numberOfStatementsOnThisLine = 0;
|
|
11750
11881
|
let firstExtraStatement = null;
|
|
@@ -11789,55 +11920,16 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11789
11920
|
lastStatementLine = line;
|
|
11790
11921
|
}
|
|
11791
11922
|
}
|
|
11792
|
-
|
|
11793
|
-
"BreakStatement": enterStatement,
|
|
11794
|
-
"ClassDeclaration": enterStatement,
|
|
11795
|
-
"ContinueStatement": enterStatement,
|
|
11796
|
-
"DebuggerStatement": enterStatement,
|
|
11797
|
-
"DoWhileStatement": enterStatement,
|
|
11798
|
-
"ExpressionStatement": enterStatement,
|
|
11799
|
-
"ForInStatement": enterStatement,
|
|
11800
|
-
"ForOfStatement": enterStatement,
|
|
11801
|
-
"ForStatement": enterStatement,
|
|
11802
|
-
"FunctionDeclaration": enterStatement,
|
|
11803
|
-
"IfStatement": enterStatement,
|
|
11804
|
-
"ImportDeclaration": enterStatement,
|
|
11805
|
-
"LabeledStatement": enterStatement,
|
|
11806
|
-
"ReturnStatement": enterStatement,
|
|
11807
|
-
"SwitchStatement": enterStatement,
|
|
11808
|
-
"ThrowStatement": enterStatement,
|
|
11809
|
-
"TryStatement": enterStatement,
|
|
11810
|
-
"VariableDeclaration": enterStatement,
|
|
11811
|
-
"WhileStatement": enterStatement,
|
|
11812
|
-
"WithStatement": enterStatement,
|
|
11813
|
-
"ExportNamedDeclaration": enterStatement,
|
|
11814
|
-
"ExportDefaultDeclaration": enterStatement,
|
|
11815
|
-
"ExportAllDeclaration": enterStatement,
|
|
11816
|
-
"BreakStatement:exit": leaveStatement,
|
|
11817
|
-
"ClassDeclaration:exit": leaveStatement,
|
|
11818
|
-
"ContinueStatement:exit": leaveStatement,
|
|
11819
|
-
"DebuggerStatement:exit": leaveStatement,
|
|
11820
|
-
"DoWhileStatement:exit": leaveStatement,
|
|
11821
|
-
"ExpressionStatement:exit": leaveStatement,
|
|
11822
|
-
"ForInStatement:exit": leaveStatement,
|
|
11823
|
-
"ForOfStatement:exit": leaveStatement,
|
|
11824
|
-
"ForStatement:exit": leaveStatement,
|
|
11825
|
-
"FunctionDeclaration:exit": leaveStatement,
|
|
11826
|
-
"IfStatement:exit": leaveStatement,
|
|
11827
|
-
"ImportDeclaration:exit": leaveStatement,
|
|
11828
|
-
"LabeledStatement:exit": leaveStatement,
|
|
11829
|
-
"ReturnStatement:exit": leaveStatement,
|
|
11830
|
-
"SwitchStatement:exit": leaveStatement,
|
|
11831
|
-
"ThrowStatement:exit": leaveStatement,
|
|
11832
|
-
"TryStatement:exit": leaveStatement,
|
|
11833
|
-
"VariableDeclaration:exit": leaveStatement,
|
|
11834
|
-
"WhileStatement:exit": leaveStatement,
|
|
11835
|
-
"WithStatement:exit": leaveStatement,
|
|
11836
|
-
"ExportNamedDeclaration:exit": leaveStatement,
|
|
11837
|
-
"ExportDefaultDeclaration:exit": leaveStatement,
|
|
11838
|
-
"ExportAllDeclaration:exit": leaveStatement,
|
|
11923
|
+
const listeners = {
|
|
11839
11924
|
"Program:exit": reportFirstExtraStatementAndClear
|
|
11840
11925
|
};
|
|
11926
|
+
for (const node of listeningNodes) {
|
|
11927
|
+
if (ignoredNodes.includes(node))
|
|
11928
|
+
continue;
|
|
11929
|
+
listeners[node] = enterStatement;
|
|
11930
|
+
listeners[`${node}:exit`] = leaveStatement;
|
|
11931
|
+
}
|
|
11932
|
+
return listeners;
|
|
11841
11933
|
}
|
|
11842
11934
|
});
|
|
11843
11935
|
module2.exports = maxStatementsPerLine;
|
|
@@ -14145,7 +14237,7 @@ var require_no_multi_spaces = __commonJS({
|
|
|
14145
14237
|
const sourceCode = context.sourceCode;
|
|
14146
14238
|
const options = context.options[0] || {};
|
|
14147
14239
|
const ignoreEOLComments = options.ignoreEOLComments;
|
|
14148
|
-
const exceptions = Object.assign({ Property: true }, options.exceptions);
|
|
14240
|
+
const exceptions = Object.assign({ Property: true, ImportAttribute: true }, options.exceptions);
|
|
14149
14241
|
const hasExceptions = Object.keys(exceptions).some((key) => exceptions[key]);
|
|
14150
14242
|
const spacesRe = options.includeTabs === false ? / {2}/ : /[ \t]{2}/;
|
|
14151
14243
|
function formatReportedCommentValue(token) {
|
|
@@ -15991,9 +16083,11 @@ var require_padding_line_between_statements = __commonJS({
|
|
|
15991
16083
|
test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && node.type === utils.AST_NODE_TYPES.ExpressionStatement && !isDirectivePrologue(node, sourceCode)
|
|
15992
16084
|
},
|
|
15993
16085
|
"multiline-const": newMultilineKeywordTester("const"),
|
|
16086
|
+
"multiline-export": newMultilineKeywordTester("export"),
|
|
15994
16087
|
"multiline-let": newMultilineKeywordTester("let"),
|
|
15995
16088
|
"multiline-var": newMultilineKeywordTester("var"),
|
|
15996
16089
|
"singleline-const": newSinglelineKeywordTester("const"),
|
|
16090
|
+
"singleline-export": newSinglelineKeywordTester("export"),
|
|
15997
16091
|
"singleline-let": newSinglelineKeywordTester("let"),
|
|
15998
16092
|
"singleline-var": newSinglelineKeywordTester("var"),
|
|
15999
16093
|
"block": newNodeTypeTester(utils.AST_NODE_TYPES.BlockStatement),
|
|
@@ -16310,7 +16404,7 @@ var require_quote_props = __commonJS({
|
|
|
16310
16404
|
}
|
|
16311
16405
|
function checkUnnecessaryQuotes(node) {
|
|
16312
16406
|
const key = node.key;
|
|
16313
|
-
if (node.method || node.computed || node.shorthand)
|
|
16407
|
+
if (node.type !== "ImportAttribute" && (node.method || node.computed || node.shorthand))
|
|
16314
16408
|
return;
|
|
16315
16409
|
if (key.type === "Literal" && typeof key.value === "string") {
|
|
16316
16410
|
let tokens;
|
|
@@ -16349,26 +16443,39 @@ var require_quote_props = __commonJS({
|
|
|
16349
16443
|
}
|
|
16350
16444
|
}
|
|
16351
16445
|
function checkOmittedQuotes(node) {
|
|
16446
|
+
if (node.type !== "ImportAttribute" && (node.method || node.computed || node.shorthand))
|
|
16447
|
+
return;
|
|
16352
16448
|
const key = node.key;
|
|
16353
|
-
if (
|
|
16354
|
-
|
|
16355
|
-
|
|
16356
|
-
|
|
16357
|
-
|
|
16358
|
-
|
|
16359
|
-
|
|
16360
|
-
}
|
|
16449
|
+
if (key.type === "Literal" && typeof key.value === "string")
|
|
16450
|
+
return;
|
|
16451
|
+
context.report({
|
|
16452
|
+
node,
|
|
16453
|
+
messageId: "unquotedPropertyFound",
|
|
16454
|
+
data: { property: key.name || key.value },
|
|
16455
|
+
fix: (fixer) => fixer.replaceText(key, getQuotedKey(key))
|
|
16456
|
+
});
|
|
16457
|
+
}
|
|
16458
|
+
function checkConsistencyForObject(node, checkQuotesRedundancy) {
|
|
16459
|
+
checkConsistency(
|
|
16460
|
+
node.properties.filter((property) => property.type !== "SpreadElement" && property.key && !property.method && !property.computed && !property.shorthand),
|
|
16461
|
+
checkQuotesRedundancy
|
|
16462
|
+
);
|
|
16463
|
+
}
|
|
16464
|
+
function checkImportAttributes(attributes) {
|
|
16465
|
+
if (!attributes)
|
|
16466
|
+
return;
|
|
16467
|
+
if (MODE === "consistent")
|
|
16468
|
+
checkConsistency(attributes, false);
|
|
16469
|
+
if (MODE === "consistent-as-needed")
|
|
16470
|
+
checkConsistency(attributes, true);
|
|
16361
16471
|
}
|
|
16362
|
-
function checkConsistency(
|
|
16472
|
+
function checkConsistency(properties, checkQuotesRedundancy) {
|
|
16363
16473
|
const quotedProps = [];
|
|
16364
16474
|
const unquotedProps = [];
|
|
16365
16475
|
let keywordKeyName = null;
|
|
16366
16476
|
let necessaryQuotes = false;
|
|
16367
|
-
|
|
16368
|
-
const property = rawProperty;
|
|
16477
|
+
properties.forEach((property) => {
|
|
16369
16478
|
const key = property.key;
|
|
16370
|
-
if (!key || property.method || property.computed || property.shorthand)
|
|
16371
|
-
return;
|
|
16372
16479
|
if (key.type === "Literal" && typeof key.value === "string") {
|
|
16373
16480
|
quotedProps.push(property);
|
|
16374
16481
|
if (checkQuotesRedundancy) {
|
|
@@ -16427,9 +16534,24 @@ var require_quote_props = __commonJS({
|
|
|
16427
16534
|
},
|
|
16428
16535
|
ObjectExpression(node) {
|
|
16429
16536
|
if (MODE === "consistent")
|
|
16430
|
-
|
|
16537
|
+
checkConsistencyForObject(node, false);
|
|
16431
16538
|
if (MODE === "consistent-as-needed")
|
|
16432
|
-
|
|
16539
|
+
checkConsistencyForObject(node, true);
|
|
16540
|
+
},
|
|
16541
|
+
ImportAttribute(node) {
|
|
16542
|
+
if (MODE === "always" || !MODE)
|
|
16543
|
+
checkOmittedQuotes(node);
|
|
16544
|
+
if (MODE === "as-needed")
|
|
16545
|
+
checkUnnecessaryQuotes(node);
|
|
16546
|
+
},
|
|
16547
|
+
ImportDeclaration(node) {
|
|
16548
|
+
checkImportAttributes(node.attributes);
|
|
16549
|
+
},
|
|
16550
|
+
ExportAllDeclaration(node) {
|
|
16551
|
+
checkImportAttributes(node.attributes);
|
|
16552
|
+
},
|
|
16553
|
+
ExportNamedDeclaration(node) {
|
|
16554
|
+
checkImportAttributes(node.attributes);
|
|
16433
16555
|
}
|
|
16434
16556
|
};
|
|
16435
16557
|
}
|
|
@@ -17593,7 +17715,7 @@ var require_space_before_blocks = __commonJS({
|
|
|
17593
17715
|
function checkPrecedingSpace(node) {
|
|
17594
17716
|
const precedingToken = sourceCode.getTokenBefore(node);
|
|
17595
17717
|
if (precedingToken && astUtils.isTokenOnSameLine(precedingToken, node)) {
|
|
17596
|
-
const hasSpace = sourceCode.
|
|
17718
|
+
const hasSpace = sourceCode.isSpaceBetween(
|
|
17597
17719
|
precedingToken,
|
|
17598
17720
|
node
|
|
17599
17721
|
);
|
|
@@ -17723,7 +17845,7 @@ var require_space_before_function_paren = __commonJS({
|
|
|
17723
17845
|
rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
|
|
17724
17846
|
leftToken = sourceCode.getTokenBefore(rightToken);
|
|
17725
17847
|
}
|
|
17726
|
-
const hasSpacing = sourceCode.
|
|
17848
|
+
const hasSpacing = sourceCode.isSpaceBetween(leftToken, rightToken);
|
|
17727
17849
|
if (hasSpacing && functionConfig === "never") {
|
|
17728
17850
|
context.report({
|
|
17729
17851
|
node,
|
|
@@ -19031,10 +19153,7 @@ var require_type_annotation_spacing = __commonJS({
|
|
|
19031
19153
|
return;
|
|
19032
19154
|
const { before, after } = getRules(ruleSet, typeAnnotation);
|
|
19033
19155
|
if (type === ":" && previousToken.value === "?") {
|
|
19034
|
-
if (
|
|
19035
|
-
// -- TODO - switch once our min ESLint version is 6.7.0
|
|
19036
|
-
sourceCode.isSpaceBetweenTokens(previousToken, punctuatorTokenStart)
|
|
19037
|
-
) {
|
|
19156
|
+
if (sourceCode.isSpaceBetween(previousToken, punctuatorTokenStart)) {
|
|
19038
19157
|
context.report({
|
|
19039
19158
|
node: punctuatorTokenStart,
|
|
19040
19159
|
messageId: "unexpectedSpaceBetween",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/eslint-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
4
4
|
"description": "Shared ESLint configurations and extras",
|
|
5
5
|
"main": "./index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "eslint"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"eslint": "^9.
|
|
13
|
+
"eslint": "^9.13.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"*.md",
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/plugjs/eslint-plugin#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@eslint/js": "9.
|
|
38
|
+
"@eslint/js": "9.13.0",
|
|
39
39
|
"@nolyfill/is-core-module": "1.0.39",
|
|
40
|
-
"@typescript-eslint/utils": "8.
|
|
40
|
+
"@typescript-eslint/utils": "8.12.2",
|
|
41
41
|
"debug": "4.3.7",
|
|
42
42
|
"doctrine": "3.0.0",
|
|
43
43
|
"enhanced-resolve": "5.17.1",
|
|
44
|
-
"eslint": "9.
|
|
44
|
+
"eslint": "9.13.0",
|
|
45
45
|
"eslint-module-utils": "2.12.0",
|
|
46
46
|
"eslint-plugin-unicorn": "56.0.0",
|
|
47
|
-
"eslint-visitor-keys": "4.
|
|
48
|
-
"espree": "10.
|
|
47
|
+
"eslint-visitor-keys": "4.2.0",
|
|
48
|
+
"espree": "10.3.0",
|
|
49
49
|
"estraverse": "5.3.0",
|
|
50
50
|
"fast-glob": "3.3.2",
|
|
51
51
|
"get-tsconfig": "4.8.1",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"resolve": "1.22.8",
|
|
59
59
|
"semver": "7.6.3",
|
|
60
60
|
"stable-hash": "0.0.4",
|
|
61
|
-
"tslib": "2.8.
|
|
61
|
+
"tslib": "2.8.1",
|
|
62
62
|
"typescript": "5.6.3",
|
|
63
|
-
"typescript-eslint": "8.
|
|
63
|
+
"typescript-eslint": "8.12.2"
|
|
64
64
|
}
|
|
65
65
|
}
|