@plugjs/eslint-plugin 0.2.23 → 0.2.25
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/bundles/eslint-plugin-import-x.cjs +43 -29
- package/bundles/stylistic-eslint-plugin.cjs +274 -156
- package/package.json +10 -10
|
@@ -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,41 @@ 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
|
+
}
|
|
5731
5804
|
function handler(node, right) {
|
|
5732
5805
|
if (node.loc.start.line === node.loc.end.line)
|
|
5733
5806
|
return;
|
|
@@ -5747,8 +5820,10 @@ var require_indent_binary_ops = __commonJS({
|
|
|
5747
5820
|
const firstTokenOfLineLeft = firstTokenOfLine(tokenLeft.loc.start.line);
|
|
5748
5821
|
const lastTokenOfLineLeft = lastTokenOfLine(tokenLeft.loc.start.line);
|
|
5749
5822
|
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
|
|
5823
|
+
const needSubtractionIndent = lastTokenOfLineLeft?.value === ")" && isGreaterThanCloseBracketOfLine(tokenLeft.loc.start.line) && !["]", ")", "}"].includes(firstTokenOfLineLeft?.value || "");
|
|
5824
|
+
const indentLeft = getIndentOfLine(tokenLeft.loc.start.line);
|
|
5751
5825
|
const indentRight = getIndentOfLine(tokenRight.loc.start.line);
|
|
5826
|
+
const indentTarget = getTargetIndent(indentLeft, needAdditionIndent, needSubtractionIndent);
|
|
5752
5827
|
if (indentTarget !== indentRight) {
|
|
5753
5828
|
const start = {
|
|
5754
5829
|
line: tokenRight.loc.start.line,
|
|
@@ -6093,26 +6168,21 @@ var require_jsx_closing_bracket_location = __commonJS({
|
|
|
6093
6168
|
openingStartOfLine
|
|
6094
6169
|
};
|
|
6095
6170
|
}
|
|
6096
|
-
function getOpeningElementId(node) {
|
|
6097
|
-
return node.range.join(":");
|
|
6098
|
-
}
|
|
6099
|
-
const lastAttributeNode = {};
|
|
6100
6171
|
return {
|
|
6101
|
-
JSXAttribute(node) {
|
|
6102
|
-
lastAttributeNode[getOpeningElementId(node.parent)] = node;
|
|
6103
|
-
},
|
|
6104
|
-
JSXSpreadAttribute(node) {
|
|
6105
|
-
lastAttributeNode[getOpeningElementId(node.parent)] = node;
|
|
6106
|
-
},
|
|
6107
6172
|
"JSXOpeningElement:exit": function(node) {
|
|
6108
|
-
const
|
|
6109
|
-
const cachedLastAttributeEndPos =
|
|
6173
|
+
const lastAttributeNode = node.attributes.at(-1);
|
|
6174
|
+
const cachedLastAttributeEndPos = lastAttributeNode ? lastAttributeNode.range[1] : null;
|
|
6110
6175
|
let expectedNextLine;
|
|
6111
6176
|
const tokens = getTokensLocations(node);
|
|
6112
|
-
|
|
6177
|
+
let expectedLocation = getExpectedLocation(tokens);
|
|
6113
6178
|
let usingSameIndentation = true;
|
|
6114
6179
|
if (expectedLocation === "tag-aligned")
|
|
6115
6180
|
usingSameIndentation = tokens.isTab.openTab === tokens.isTab.closeTab;
|
|
6181
|
+
const lastComment = context.sourceCode.getCommentsInside(node).at(-1);
|
|
6182
|
+
const hasTrailingComment = lastComment && lastComment.range[0] > (lastAttributeNode ?? node.name).range[1];
|
|
6183
|
+
if ((expectedLocation === "after-props" || expectedLocation === "after-tag") && !(hasCorrectLocation(tokens, expectedLocation) && usingSameIndentation) && hasTrailingComment) {
|
|
6184
|
+
expectedLocation = "line-aligned";
|
|
6185
|
+
}
|
|
6116
6186
|
if (hasCorrectLocation(tokens, expectedLocation) && usingSameIndentation)
|
|
6117
6187
|
return;
|
|
6118
6188
|
const data = {
|
|
@@ -6140,9 +6210,11 @@ var require_jsx_closing_bracket_location = __commonJS({
|
|
|
6140
6210
|
return fixer.replaceTextRange([cachedLastAttributeEndPos, node.range[1]], (expectedNextLine ? "\n" : "") + closingTag);
|
|
6141
6211
|
case "props-aligned":
|
|
6142
6212
|
case "tag-aligned":
|
|
6143
|
-
case "line-aligned":
|
|
6144
|
-
|
|
6213
|
+
case "line-aligned": {
|
|
6214
|
+
const rangeStart = hasTrailingComment ? lastComment.range[1] : cachedLastAttributeEndPos;
|
|
6215
|
+
return fixer.replaceTextRange([rangeStart, node.range[1]], `
|
|
6145
6216
|
${getIndentation(tokens, expectedLocation, correctColumn)}${closingTag}`);
|
|
6217
|
+
}
|
|
6146
6218
|
}
|
|
6147
6219
|
return null;
|
|
6148
6220
|
}
|
|
@@ -9412,6 +9484,11 @@ var require_key_spacing = __commonJS({
|
|
|
9412
9484
|
function isSingleLine(node) {
|
|
9413
9485
|
return node.loc.end.line === node.loc.start.line;
|
|
9414
9486
|
}
|
|
9487
|
+
function isSingleLineImportAttributes(node, sourceCode) {
|
|
9488
|
+
const openingBrace = sourceCode.getTokenBefore(node.attributes[0], utils.isOpeningBraceToken);
|
|
9489
|
+
const closingBrace = sourceCode.getTokenAfter(node.attributes[node.attributes.length - 1], utils.isClosingBraceToken);
|
|
9490
|
+
return closingBrace.loc.end.line === openingBrace.loc.start.line;
|
|
9491
|
+
}
|
|
9415
9492
|
function isSingleLineProperties(properties) {
|
|
9416
9493
|
const [firstProp] = properties;
|
|
9417
9494
|
const lastProp = last(properties);
|
|
@@ -9658,6 +9735,8 @@ var require_key_spacing = __commonJS({
|
|
|
9658
9735
|
const alignmentOptions = ruleOptions.align || null;
|
|
9659
9736
|
const sourceCode = context.sourceCode;
|
|
9660
9737
|
function isKeyValueProperty(property) {
|
|
9738
|
+
if (property.type === "ImportAttribute")
|
|
9739
|
+
return true;
|
|
9661
9740
|
return !("method" in property && property.method || "shorthand" in property && property.shorthand || "kind" in property && property.kind !== "init" || property.type !== "Property");
|
|
9662
9741
|
}
|
|
9663
9742
|
function getNextColon(node) {
|
|
@@ -9688,7 +9767,7 @@ var require_key_spacing = __commonJS({
|
|
|
9688
9767
|
}
|
|
9689
9768
|
function getKey(property) {
|
|
9690
9769
|
const key = property.key;
|
|
9691
|
-
if (property.computed)
|
|
9770
|
+
if (property.type !== "ImportAttribute" && property.computed)
|
|
9692
9771
|
return sourceCode.getText().slice(key.range[0], key.range[1]);
|
|
9693
9772
|
return utils.getStaticPropertyName(property);
|
|
9694
9773
|
}
|
|
@@ -9737,7 +9816,7 @@ var require_key_spacing = __commonJS({
|
|
|
9737
9816
|
loc,
|
|
9738
9817
|
messageId,
|
|
9739
9818
|
data: {
|
|
9740
|
-
computed: property.computed ? "computed " : "",
|
|
9819
|
+
computed: property.type !== "ImportAttribute" && property.computed ? "computed " : "",
|
|
9741
9820
|
key: getKey(property)
|
|
9742
9821
|
},
|
|
9743
9822
|
fix
|
|
@@ -9762,10 +9841,10 @@ var require_key_spacing = __commonJS({
|
|
|
9762
9841
|
}
|
|
9763
9842
|
return null;
|
|
9764
9843
|
}
|
|
9765
|
-
function createGroups(
|
|
9766
|
-
if (
|
|
9767
|
-
return [
|
|
9768
|
-
return
|
|
9844
|
+
function createGroups(properties) {
|
|
9845
|
+
if (properties.length === 1)
|
|
9846
|
+
return [properties];
|
|
9847
|
+
return properties.reduce((groups, property) => {
|
|
9769
9848
|
const currentGroup = last(groups);
|
|
9770
9849
|
const prev = last(currentGroup);
|
|
9771
9850
|
if (!prev || continuesPropertyGroup(prev, property))
|
|
@@ -9822,39 +9901,57 @@ var require_key_spacing = __commonJS({
|
|
|
9822
9901
|
for (let i = 0; i < length; i++)
|
|
9823
9902
|
verifySpacing(properties[i], lineOptions);
|
|
9824
9903
|
}
|
|
9825
|
-
function verifyAlignment(
|
|
9826
|
-
createGroups(
|
|
9827
|
-
const
|
|
9828
|
-
if (
|
|
9829
|
-
verifyListSpacing(
|
|
9904
|
+
function verifyAlignment(properties) {
|
|
9905
|
+
createGroups(properties).forEach((group) => {
|
|
9906
|
+
const properties2 = group.filter(isKeyValueProperty);
|
|
9907
|
+
if (properties2.length > 0 && isSingleLineProperties(properties2))
|
|
9908
|
+
verifyListSpacing(properties2, multiLineOptions);
|
|
9830
9909
|
else
|
|
9831
|
-
verifyGroupAlignment(
|
|
9910
|
+
verifyGroupAlignment(properties2);
|
|
9832
9911
|
});
|
|
9833
9912
|
}
|
|
9913
|
+
function verifyImportAttributes(node) {
|
|
9914
|
+
if (!node.attributes)
|
|
9915
|
+
return;
|
|
9916
|
+
if (!node.attributes.length)
|
|
9917
|
+
return;
|
|
9918
|
+
if (isSingleLineImportAttributes(node, sourceCode))
|
|
9919
|
+
verifyListSpacing(node.attributes, singleLineOptions);
|
|
9920
|
+
else
|
|
9921
|
+
verifyAlignment(node.attributes);
|
|
9922
|
+
}
|
|
9834
9923
|
if (alignmentOptions) {
|
|
9835
9924
|
return {
|
|
9836
9925
|
ObjectExpression(node) {
|
|
9837
9926
|
if (isSingleLine(node))
|
|
9838
9927
|
verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions);
|
|
9839
9928
|
else
|
|
9840
|
-
verifyAlignment(node);
|
|
9929
|
+
verifyAlignment(node.properties);
|
|
9930
|
+
},
|
|
9931
|
+
ImportDeclaration(node) {
|
|
9932
|
+
verifyImportAttributes(node);
|
|
9933
|
+
},
|
|
9934
|
+
ExportNamedDeclaration(node) {
|
|
9935
|
+
verifyImportAttributes(node);
|
|
9936
|
+
},
|
|
9937
|
+
ExportAllDeclaration(node) {
|
|
9938
|
+
verifyImportAttributes(node);
|
|
9841
9939
|
}
|
|
9842
9940
|
};
|
|
9843
9941
|
}
|
|
9844
9942
|
return {
|
|
9845
9943
|
Property(node) {
|
|
9846
9944
|
verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
|
|
9945
|
+
},
|
|
9946
|
+
ImportAttribute(node) {
|
|
9947
|
+
const parent = node.parent;
|
|
9948
|
+
verifySpacing(node, isSingleLineImportAttributes(parent, sourceCode) ? singleLineOptions : multiLineOptions);
|
|
9847
9949
|
}
|
|
9848
9950
|
};
|
|
9849
9951
|
}
|
|
9850
9952
|
});
|
|
9851
9953
|
var baseRule = /* @__PURE__ */ utils.castRuleModule(_baseRule);
|
|
9852
9954
|
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
9955
|
var keySpacing = utils.createRule({
|
|
9859
9956
|
name: "key-spacing",
|
|
9860
9957
|
package: "ts",
|
|
@@ -9876,7 +9973,7 @@ var require_key_spacing = __commonJS({
|
|
|
9876
9973
|
function adjustedColumn(position) {
|
|
9877
9974
|
const line = position.line - 1;
|
|
9878
9975
|
return utils.getStringLength(
|
|
9879
|
-
|
|
9976
|
+
sourceCode.lines.at(line).slice(0, position.column)
|
|
9880
9977
|
);
|
|
9881
9978
|
}
|
|
9882
9979
|
function getLastTokenBeforeColon(node) {
|
|
@@ -9896,14 +9993,14 @@ var require_key_spacing = __commonJS({
|
|
|
9896
9993
|
return code.slice(
|
|
9897
9994
|
0,
|
|
9898
9995
|
sourceCode.getTokenAfter(
|
|
9899
|
-
|
|
9996
|
+
node.parameters.at(-1),
|
|
9900
9997
|
astUtils.isClosingBracketToken
|
|
9901
9998
|
).range[1] - node.range[0]
|
|
9902
9999
|
);
|
|
9903
10000
|
}
|
|
9904
10001
|
function getKeyLocEnd(node) {
|
|
9905
10002
|
return getLastTokenBeforeColon(
|
|
9906
|
-
node.type !== utils$1.AST_NODE_TYPES.TSIndexSignature ? node.key :
|
|
10003
|
+
node.type !== utils$1.AST_NODE_TYPES.TSIndexSignature ? node.key : node.parameters.at(-1)
|
|
9907
10004
|
).loc.end;
|
|
9908
10005
|
}
|
|
9909
10006
|
function checkBeforeColon(node, expectedWhitespaceBeforeColon, mode) {
|
|
@@ -9969,7 +10066,7 @@ var require_key_spacing = __commonJS({
|
|
|
9969
10066
|
if (candidateValueStartLine - groupEndLine === 1)
|
|
9970
10067
|
return true;
|
|
9971
10068
|
const leadingComments = sourceCode.getCommentsBefore(candidate);
|
|
9972
|
-
if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - at(
|
|
10069
|
+
if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - leadingComments.at(-1).loc.end.line <= 1) {
|
|
9973
10070
|
for (let i = 1; i < leadingComments.length; i++) {
|
|
9974
10071
|
if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
|
|
9975
10072
|
return false;
|
|
@@ -10048,7 +10145,7 @@ var require_key_spacing = __commonJS({
|
|
|
10048
10145
|
alignGroups.push(currentAlignGroup);
|
|
10049
10146
|
let prevNode;
|
|
10050
10147
|
for (const node of members) {
|
|
10051
|
-
let prevAlignedNode = at(
|
|
10148
|
+
let prevAlignedNode = currentAlignGroup.at(-1);
|
|
10052
10149
|
if (prevAlignedNode !== prevNode)
|
|
10053
10150
|
prevAlignedNode = void 0;
|
|
10054
10151
|
if (prevAlignedNode && continuesAlignGroup(prevAlignedNode, node)) {
|
|
@@ -11716,6 +11813,31 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11716
11813
|
require("eslint-visitor-keys");
|
|
11717
11814
|
require("espree");
|
|
11718
11815
|
require("estraverse");
|
|
11816
|
+
var listeningNodes = [
|
|
11817
|
+
"BreakStatement",
|
|
11818
|
+
"ClassDeclaration",
|
|
11819
|
+
"ContinueStatement",
|
|
11820
|
+
"DebuggerStatement",
|
|
11821
|
+
"DoWhileStatement",
|
|
11822
|
+
"ExpressionStatement",
|
|
11823
|
+
"ForInStatement",
|
|
11824
|
+
"ForOfStatement",
|
|
11825
|
+
"ForStatement",
|
|
11826
|
+
"FunctionDeclaration",
|
|
11827
|
+
"IfStatement",
|
|
11828
|
+
"ImportDeclaration",
|
|
11829
|
+
"LabeledStatement",
|
|
11830
|
+
"ReturnStatement",
|
|
11831
|
+
"SwitchStatement",
|
|
11832
|
+
"ThrowStatement",
|
|
11833
|
+
"TryStatement",
|
|
11834
|
+
"VariableDeclaration",
|
|
11835
|
+
"WhileStatement",
|
|
11836
|
+
"WithStatement",
|
|
11837
|
+
"ExportNamedDeclaration",
|
|
11838
|
+
"ExportDefaultDeclaration",
|
|
11839
|
+
"ExportAllDeclaration"
|
|
11840
|
+
];
|
|
11719
11841
|
var maxStatementsPerLine = utils.createRule({
|
|
11720
11842
|
name: "max-statements-per-line",
|
|
11721
11843
|
package: "js",
|
|
@@ -11732,6 +11854,13 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11732
11854
|
type: "integer",
|
|
11733
11855
|
minimum: 1,
|
|
11734
11856
|
default: 1
|
|
11857
|
+
},
|
|
11858
|
+
ignoredNodes: {
|
|
11859
|
+
type: "array",
|
|
11860
|
+
items: {
|
|
11861
|
+
type: "string",
|
|
11862
|
+
enum: listeningNodes
|
|
11863
|
+
}
|
|
11735
11864
|
}
|
|
11736
11865
|
},
|
|
11737
11866
|
additionalProperties: false
|
|
@@ -11745,6 +11874,7 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11745
11874
|
const sourceCode = context.sourceCode;
|
|
11746
11875
|
const options = context.options[0] || {};
|
|
11747
11876
|
const maxStatementsPerLine2 = typeof options.max !== "undefined" ? options.max : 1;
|
|
11877
|
+
const ignoredNodes = options.ignoredNodes || [];
|
|
11748
11878
|
let lastStatementLine = 0;
|
|
11749
11879
|
let numberOfStatementsOnThisLine = 0;
|
|
11750
11880
|
let firstExtraStatement = null;
|
|
@@ -11789,55 +11919,16 @@ var require_max_statements_per_line = __commonJS({
|
|
|
11789
11919
|
lastStatementLine = line;
|
|
11790
11920
|
}
|
|
11791
11921
|
}
|
|
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,
|
|
11922
|
+
const listeners = {
|
|
11839
11923
|
"Program:exit": reportFirstExtraStatementAndClear
|
|
11840
11924
|
};
|
|
11925
|
+
for (const node of listeningNodes) {
|
|
11926
|
+
if (ignoredNodes.includes(node))
|
|
11927
|
+
continue;
|
|
11928
|
+
listeners[node] = enterStatement;
|
|
11929
|
+
listeners[`${node}:exit`] = leaveStatement;
|
|
11930
|
+
}
|
|
11931
|
+
return listeners;
|
|
11841
11932
|
}
|
|
11842
11933
|
});
|
|
11843
11934
|
module2.exports = maxStatementsPerLine;
|
|
@@ -14145,7 +14236,7 @@ var require_no_multi_spaces = __commonJS({
|
|
|
14145
14236
|
const sourceCode = context.sourceCode;
|
|
14146
14237
|
const options = context.options[0] || {};
|
|
14147
14238
|
const ignoreEOLComments = options.ignoreEOLComments;
|
|
14148
|
-
const exceptions = Object.assign({ Property: true }, options.exceptions);
|
|
14239
|
+
const exceptions = Object.assign({ Property: true, ImportAttribute: true }, options.exceptions);
|
|
14149
14240
|
const hasExceptions = Object.keys(exceptions).some((key) => exceptions[key]);
|
|
14150
14241
|
const spacesRe = options.includeTabs === false ? / {2}/ : /[ \t]{2}/;
|
|
14151
14242
|
function formatReportedCommentValue(token) {
|
|
@@ -15991,9 +16082,11 @@ var require_padding_line_between_statements = __commonJS({
|
|
|
15991
16082
|
test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && node.type === utils.AST_NODE_TYPES.ExpressionStatement && !isDirectivePrologue(node, sourceCode)
|
|
15992
16083
|
},
|
|
15993
16084
|
"multiline-const": newMultilineKeywordTester("const"),
|
|
16085
|
+
"multiline-export": newMultilineKeywordTester("export"),
|
|
15994
16086
|
"multiline-let": newMultilineKeywordTester("let"),
|
|
15995
16087
|
"multiline-var": newMultilineKeywordTester("var"),
|
|
15996
16088
|
"singleline-const": newSinglelineKeywordTester("const"),
|
|
16089
|
+
"singleline-export": newSinglelineKeywordTester("export"),
|
|
15997
16090
|
"singleline-let": newSinglelineKeywordTester("let"),
|
|
15998
16091
|
"singleline-var": newSinglelineKeywordTester("var"),
|
|
15999
16092
|
"block": newNodeTypeTester(utils.AST_NODE_TYPES.BlockStatement),
|
|
@@ -16310,7 +16403,7 @@ var require_quote_props = __commonJS({
|
|
|
16310
16403
|
}
|
|
16311
16404
|
function checkUnnecessaryQuotes(node) {
|
|
16312
16405
|
const key = node.key;
|
|
16313
|
-
if (node.method || node.computed || node.shorthand)
|
|
16406
|
+
if (node.type !== "ImportAttribute" && (node.method || node.computed || node.shorthand))
|
|
16314
16407
|
return;
|
|
16315
16408
|
if (key.type === "Literal" && typeof key.value === "string") {
|
|
16316
16409
|
let tokens;
|
|
@@ -16349,26 +16442,39 @@ var require_quote_props = __commonJS({
|
|
|
16349
16442
|
}
|
|
16350
16443
|
}
|
|
16351
16444
|
function checkOmittedQuotes(node) {
|
|
16445
|
+
if (node.type !== "ImportAttribute" && (node.method || node.computed || node.shorthand))
|
|
16446
|
+
return;
|
|
16352
16447
|
const key = node.key;
|
|
16353
|
-
if (
|
|
16354
|
-
|
|
16355
|
-
|
|
16356
|
-
|
|
16357
|
-
|
|
16358
|
-
|
|
16359
|
-
|
|
16360
|
-
}
|
|
16448
|
+
if (key.type === "Literal" && typeof key.value === "string")
|
|
16449
|
+
return;
|
|
16450
|
+
context.report({
|
|
16451
|
+
node,
|
|
16452
|
+
messageId: "unquotedPropertyFound",
|
|
16453
|
+
data: { property: key.name || key.value },
|
|
16454
|
+
fix: (fixer) => fixer.replaceText(key, getQuotedKey(key))
|
|
16455
|
+
});
|
|
16456
|
+
}
|
|
16457
|
+
function checkConsistencyForObject(node, checkQuotesRedundancy) {
|
|
16458
|
+
checkConsistency(
|
|
16459
|
+
node.properties.filter((property) => property.type !== "SpreadElement" && property.key && !property.method && !property.computed && !property.shorthand),
|
|
16460
|
+
checkQuotesRedundancy
|
|
16461
|
+
);
|
|
16462
|
+
}
|
|
16463
|
+
function checkImportAttributes(attributes) {
|
|
16464
|
+
if (!attributes)
|
|
16465
|
+
return;
|
|
16466
|
+
if (MODE === "consistent")
|
|
16467
|
+
checkConsistency(attributes, false);
|
|
16468
|
+
if (MODE === "consistent-as-needed")
|
|
16469
|
+
checkConsistency(attributes, true);
|
|
16361
16470
|
}
|
|
16362
|
-
function checkConsistency(
|
|
16471
|
+
function checkConsistency(properties, checkQuotesRedundancy) {
|
|
16363
16472
|
const quotedProps = [];
|
|
16364
16473
|
const unquotedProps = [];
|
|
16365
16474
|
let keywordKeyName = null;
|
|
16366
16475
|
let necessaryQuotes = false;
|
|
16367
|
-
|
|
16368
|
-
const property = rawProperty;
|
|
16476
|
+
properties.forEach((property) => {
|
|
16369
16477
|
const key = property.key;
|
|
16370
|
-
if (!key || property.method || property.computed || property.shorthand)
|
|
16371
|
-
return;
|
|
16372
16478
|
if (key.type === "Literal" && typeof key.value === "string") {
|
|
16373
16479
|
quotedProps.push(property);
|
|
16374
16480
|
if (checkQuotesRedundancy) {
|
|
@@ -16427,9 +16533,24 @@ var require_quote_props = __commonJS({
|
|
|
16427
16533
|
},
|
|
16428
16534
|
ObjectExpression(node) {
|
|
16429
16535
|
if (MODE === "consistent")
|
|
16430
|
-
|
|
16536
|
+
checkConsistencyForObject(node, false);
|
|
16431
16537
|
if (MODE === "consistent-as-needed")
|
|
16432
|
-
|
|
16538
|
+
checkConsistencyForObject(node, true);
|
|
16539
|
+
},
|
|
16540
|
+
ImportAttribute(node) {
|
|
16541
|
+
if (MODE === "always" || !MODE)
|
|
16542
|
+
checkOmittedQuotes(node);
|
|
16543
|
+
if (MODE === "as-needed")
|
|
16544
|
+
checkUnnecessaryQuotes(node);
|
|
16545
|
+
},
|
|
16546
|
+
ImportDeclaration(node) {
|
|
16547
|
+
checkImportAttributes(node.attributes);
|
|
16548
|
+
},
|
|
16549
|
+
ExportAllDeclaration(node) {
|
|
16550
|
+
checkImportAttributes(node.attributes);
|
|
16551
|
+
},
|
|
16552
|
+
ExportNamedDeclaration(node) {
|
|
16553
|
+
checkImportAttributes(node.attributes);
|
|
16433
16554
|
}
|
|
16434
16555
|
};
|
|
16435
16556
|
}
|
|
@@ -17593,7 +17714,7 @@ var require_space_before_blocks = __commonJS({
|
|
|
17593
17714
|
function checkPrecedingSpace(node) {
|
|
17594
17715
|
const precedingToken = sourceCode.getTokenBefore(node);
|
|
17595
17716
|
if (precedingToken && astUtils.isTokenOnSameLine(precedingToken, node)) {
|
|
17596
|
-
const hasSpace = sourceCode.
|
|
17717
|
+
const hasSpace = sourceCode.isSpaceBetween(
|
|
17597
17718
|
precedingToken,
|
|
17598
17719
|
node
|
|
17599
17720
|
);
|
|
@@ -17723,7 +17844,7 @@ var require_space_before_function_paren = __commonJS({
|
|
|
17723
17844
|
rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
|
|
17724
17845
|
leftToken = sourceCode.getTokenBefore(rightToken);
|
|
17725
17846
|
}
|
|
17726
|
-
const hasSpacing = sourceCode.
|
|
17847
|
+
const hasSpacing = sourceCode.isSpaceBetween(leftToken, rightToken);
|
|
17727
17848
|
if (hasSpacing && functionConfig === "never") {
|
|
17728
17849
|
context.report({
|
|
17729
17850
|
node,
|
|
@@ -19031,10 +19152,7 @@ var require_type_annotation_spacing = __commonJS({
|
|
|
19031
19152
|
return;
|
|
19032
19153
|
const { before, after } = getRules(ruleSet, typeAnnotation);
|
|
19033
19154
|
if (type === ":" && previousToken.value === "?") {
|
|
19034
|
-
if (
|
|
19035
|
-
// -- TODO - switch once our min ESLint version is 6.7.0
|
|
19036
|
-
sourceCode.isSpaceBetweenTokens(previousToken, punctuatorTokenStart)
|
|
19037
|
-
) {
|
|
19155
|
+
if (sourceCode.isSpaceBetween(previousToken, punctuatorTokenStart)) {
|
|
19038
19156
|
context.report({
|
|
19039
19157
|
node: punctuatorTokenStart,
|
|
19040
19158
|
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.25",
|
|
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.14.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"*.md",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/plugjs/eslint-plugin#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@eslint/js": "9.
|
|
38
|
+
"@eslint/js": "9.14.0",
|
|
39
39
|
"@nolyfill/is-core-module": "1.0.39",
|
|
40
|
-
"@typescript-eslint/utils": "8.
|
|
40
|
+
"@typescript-eslint/utils": "8.13.0",
|
|
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.14.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",
|
|
52
|
-
"globals": "15.
|
|
52
|
+
"globals": "15.12.0",
|
|
53
53
|
"is-bun-module": "1.2.1",
|
|
54
54
|
"is-core-module": "2.15.1",
|
|
55
55
|
"is-glob": "4.0.3",
|
|
@@ -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.13.0"
|
|
64
64
|
}
|
|
65
65
|
}
|