@plugjs/eslint-plugin 0.2.20 → 0.2.21
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/stylistic-eslint-plugin.cjs +396 -57
- package/package.json +8 -8
|
@@ -2906,6 +2906,290 @@ var require_computed_property_spacing = __commonJS({
|
|
|
2906
2906
|
}
|
|
2907
2907
|
});
|
|
2908
2908
|
|
|
2909
|
+
// node_modules/@stylistic/eslint-plugin/dist/rules/curly-newline.js
|
|
2910
|
+
var require_curly_newline = __commonJS({
|
|
2911
|
+
"node_modules/@stylistic/eslint-plugin/dist/rules/curly-newline.js"(exports2, module2) {
|
|
2912
|
+
"use strict";
|
|
2913
|
+
var utils = require_utils();
|
|
2914
|
+
require("eslint-visitor-keys");
|
|
2915
|
+
require("espree");
|
|
2916
|
+
require("estraverse");
|
|
2917
|
+
var commonProperties = {
|
|
2918
|
+
multiline: {
|
|
2919
|
+
type: "boolean"
|
|
2920
|
+
},
|
|
2921
|
+
minElements: {
|
|
2922
|
+
type: "integer",
|
|
2923
|
+
minimum: 0
|
|
2924
|
+
},
|
|
2925
|
+
consistent: {
|
|
2926
|
+
type: "boolean"
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
var optionValueSchema = {
|
|
2930
|
+
oneOf: [
|
|
2931
|
+
{
|
|
2932
|
+
type: "string",
|
|
2933
|
+
enum: ["always", "never"]
|
|
2934
|
+
},
|
|
2935
|
+
{
|
|
2936
|
+
type: "object",
|
|
2937
|
+
properties: commonProperties,
|
|
2938
|
+
additionalProperties: false
|
|
2939
|
+
}
|
|
2940
|
+
]
|
|
2941
|
+
};
|
|
2942
|
+
var Specialization = /* @__PURE__ */ ((Specialization2) => {
|
|
2943
|
+
Specialization2["IfStatementConsequent"] = "IfStatementConsequent";
|
|
2944
|
+
Specialization2["IfStatementAlternative"] = "IfStatementAlternative";
|
|
2945
|
+
Specialization2["DoWhileStatement"] = "DoWhileStatement";
|
|
2946
|
+
Specialization2["ForInStatement"] = "ForInStatement";
|
|
2947
|
+
Specialization2["ForOfStatement"] = "ForOfStatement";
|
|
2948
|
+
Specialization2["ForStatement"] = "ForStatement";
|
|
2949
|
+
Specialization2["WhileStatement"] = "WhileStatement";
|
|
2950
|
+
Specialization2["SwitchStatement"] = "SwitchStatement";
|
|
2951
|
+
Specialization2["SwitchCase"] = "SwitchCase";
|
|
2952
|
+
Specialization2["TryStatementBlock"] = "TryStatementBlock";
|
|
2953
|
+
Specialization2["TryStatementHandler"] = "TryStatementHandler";
|
|
2954
|
+
Specialization2["TryStatementFinalizer"] = "TryStatementFinalizer";
|
|
2955
|
+
Specialization2["BlockStatement"] = "BlockStatement";
|
|
2956
|
+
Specialization2["ArrowFunctionExpression"] = "ArrowFunctionExpression";
|
|
2957
|
+
Specialization2["FunctionDeclaration"] = "FunctionDeclaration";
|
|
2958
|
+
Specialization2["FunctionExpression"] = "FunctionExpression";
|
|
2959
|
+
Specialization2["Property"] = "Property";
|
|
2960
|
+
Specialization2["ClassBody"] = "ClassBody";
|
|
2961
|
+
Specialization2["StaticBlock"] = "StaticBlock";
|
|
2962
|
+
Specialization2["WithStatement"] = "WithStatement";
|
|
2963
|
+
Specialization2["TSEnumBody"] = "TSEnumBody";
|
|
2964
|
+
Specialization2["TSInterfaceBody"] = "TSInterfaceBody";
|
|
2965
|
+
Specialization2["TSModuleBlock"] = "TSModuleBlock";
|
|
2966
|
+
return Specialization2;
|
|
2967
|
+
})(Specialization || {});
|
|
2968
|
+
var presets = {
|
|
2969
|
+
default: { multiline: false, minElements: Number.POSITIVE_INFINITY, consistent: true },
|
|
2970
|
+
always: { multiline: false, minElements: 0, consistent: false },
|
|
2971
|
+
never: { multiline: false, minElements: Number.POSITIVE_INFINITY, consistent: false }
|
|
2972
|
+
};
|
|
2973
|
+
function normalizeOptionValue(value) {
|
|
2974
|
+
if (value === "always") {
|
|
2975
|
+
return presets.always;
|
|
2976
|
+
}
|
|
2977
|
+
if (value === "never") {
|
|
2978
|
+
return presets.never;
|
|
2979
|
+
}
|
|
2980
|
+
if (value) {
|
|
2981
|
+
return {
|
|
2982
|
+
consistent: !!value.consistent,
|
|
2983
|
+
minElements: value.minElements ?? Number.POSITIVE_INFINITY,
|
|
2984
|
+
multiline: !!value.multiline
|
|
2985
|
+
};
|
|
2986
|
+
}
|
|
2987
|
+
return presets.default;
|
|
2988
|
+
}
|
|
2989
|
+
function normalizeOptions(options) {
|
|
2990
|
+
const value = normalizeOptionValue(options);
|
|
2991
|
+
return Object.fromEntries(
|
|
2992
|
+
Object.entries(Specialization).map(([k]) => [
|
|
2993
|
+
k,
|
|
2994
|
+
typeof options === "object" && options != null && k in options ? normalizeOptionValue(options[k]) : value
|
|
2995
|
+
])
|
|
2996
|
+
);
|
|
2997
|
+
}
|
|
2998
|
+
var curlyNewline = utils.createRule({
|
|
2999
|
+
name: "curly-newline",
|
|
3000
|
+
package: "plus",
|
|
3001
|
+
meta: {
|
|
3002
|
+
type: "layout",
|
|
3003
|
+
docs: {
|
|
3004
|
+
description: "Enforce consistent line breaks after opening and before closing braces"
|
|
3005
|
+
},
|
|
3006
|
+
fixable: "whitespace",
|
|
3007
|
+
schema: [
|
|
3008
|
+
{
|
|
3009
|
+
oneOf: [
|
|
3010
|
+
{
|
|
3011
|
+
type: "string",
|
|
3012
|
+
enum: ["always", "never"]
|
|
3013
|
+
},
|
|
3014
|
+
{
|
|
3015
|
+
type: "object",
|
|
3016
|
+
properties: {
|
|
3017
|
+
...Object.fromEntries(Object.entries(Specialization).map(([k]) => [k, optionValueSchema])),
|
|
3018
|
+
...commonProperties
|
|
3019
|
+
},
|
|
3020
|
+
additionalProperties: false
|
|
3021
|
+
}
|
|
3022
|
+
]
|
|
3023
|
+
}
|
|
3024
|
+
],
|
|
3025
|
+
messages: {
|
|
3026
|
+
unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.",
|
|
3027
|
+
unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.",
|
|
3028
|
+
expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.",
|
|
3029
|
+
expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace."
|
|
3030
|
+
}
|
|
3031
|
+
},
|
|
3032
|
+
create(context) {
|
|
3033
|
+
const sourceCode = context.sourceCode;
|
|
3034
|
+
const normalizedOptions = normalizeOptions(context.options[0]);
|
|
3035
|
+
function check(node, specialization) {
|
|
3036
|
+
const options = normalizedOptions[specialization];
|
|
3037
|
+
let openBrace;
|
|
3038
|
+
let closeBrace;
|
|
3039
|
+
let elementCount;
|
|
3040
|
+
switch (node.type) {
|
|
3041
|
+
case "SwitchStatement":
|
|
3042
|
+
closeBrace = sourceCode.getLastToken(node);
|
|
3043
|
+
openBrace = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closeBrace);
|
|
3044
|
+
elementCount = node.cases.length;
|
|
3045
|
+
break;
|
|
3046
|
+
case "StaticBlock":
|
|
3047
|
+
openBrace = sourceCode.getFirstToken(node, (token) => token.value === "{");
|
|
3048
|
+
closeBrace = sourceCode.getLastToken(node);
|
|
3049
|
+
elementCount = node.body.length;
|
|
3050
|
+
break;
|
|
3051
|
+
case "TSEnumBody":
|
|
3052
|
+
openBrace = sourceCode.getFirstToken(node);
|
|
3053
|
+
closeBrace = sourceCode.getLastToken(node);
|
|
3054
|
+
elementCount = node.members.length;
|
|
3055
|
+
break;
|
|
3056
|
+
default:
|
|
3057
|
+
openBrace = sourceCode.getFirstToken(node);
|
|
3058
|
+
closeBrace = sourceCode.getLastToken(node);
|
|
3059
|
+
elementCount = node.body.length;
|
|
3060
|
+
}
|
|
3061
|
+
let first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
|
|
3062
|
+
let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
|
|
3063
|
+
const needsLineBreaks = elementCount >= options.minElements || options.multiline && elementCount > 0 && first.loc.start.line !== last.loc.end.line;
|
|
3064
|
+
const hasCommentsFirstToken = utils.isCommentToken(first);
|
|
3065
|
+
const hasCommentsLastToken = utils.isCommentToken(last);
|
|
3066
|
+
first = sourceCode.getTokenAfter(openBrace);
|
|
3067
|
+
last = sourceCode.getTokenBefore(closeBrace);
|
|
3068
|
+
if (needsLineBreaks) {
|
|
3069
|
+
if (utils.isTokenOnSameLine(openBrace, first)) {
|
|
3070
|
+
context.report({
|
|
3071
|
+
messageId: "expectedLinebreakAfterOpeningBrace",
|
|
3072
|
+
node,
|
|
3073
|
+
loc: openBrace.loc,
|
|
3074
|
+
fix(fixer) {
|
|
3075
|
+
if (hasCommentsFirstToken)
|
|
3076
|
+
return null;
|
|
3077
|
+
return fixer.insertTextAfter(openBrace, "\n");
|
|
3078
|
+
}
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
if (utils.isTokenOnSameLine(last, closeBrace)) {
|
|
3082
|
+
context.report({
|
|
3083
|
+
messageId: "expectedLinebreakBeforeClosingBrace",
|
|
3084
|
+
node,
|
|
3085
|
+
loc: closeBrace.loc,
|
|
3086
|
+
fix(fixer) {
|
|
3087
|
+
if (hasCommentsLastToken)
|
|
3088
|
+
return null;
|
|
3089
|
+
return fixer.insertTextBefore(closeBrace, "\n");
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
} else {
|
|
3094
|
+
const consistent = options.consistent;
|
|
3095
|
+
const hasLineBreakBetweenOpenBraceAndFirst = !utils.isTokenOnSameLine(openBrace, first);
|
|
3096
|
+
const hasLineBreakBetweenCloseBraceAndLast = !utils.isTokenOnSameLine(last, closeBrace);
|
|
3097
|
+
if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) {
|
|
3098
|
+
context.report({
|
|
3099
|
+
messageId: "unexpectedLinebreakAfterOpeningBrace",
|
|
3100
|
+
node,
|
|
3101
|
+
loc: openBrace.loc,
|
|
3102
|
+
fix(fixer) {
|
|
3103
|
+
if (hasCommentsFirstToken)
|
|
3104
|
+
return null;
|
|
3105
|
+
return fixer.removeRange([
|
|
3106
|
+
openBrace.range[1],
|
|
3107
|
+
first.range[0]
|
|
3108
|
+
]);
|
|
3109
|
+
}
|
|
3110
|
+
});
|
|
3111
|
+
}
|
|
3112
|
+
if (!consistent && hasLineBreakBetweenCloseBraceAndLast || consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) {
|
|
3113
|
+
context.report({
|
|
3114
|
+
messageId: "unexpectedLinebreakBeforeClosingBrace",
|
|
3115
|
+
node,
|
|
3116
|
+
loc: closeBrace.loc,
|
|
3117
|
+
fix(fixer) {
|
|
3118
|
+
if (hasCommentsLastToken)
|
|
3119
|
+
return null;
|
|
3120
|
+
return fixer.removeRange([
|
|
3121
|
+
last.range[1],
|
|
3122
|
+
closeBrace.range[0]
|
|
3123
|
+
]);
|
|
3124
|
+
}
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
function checkBlockLike(node) {
|
|
3130
|
+
check(node, node.type);
|
|
3131
|
+
}
|
|
3132
|
+
return {
|
|
3133
|
+
BlockStatement(node) {
|
|
3134
|
+
const { parent } = node;
|
|
3135
|
+
switch (parent.type) {
|
|
3136
|
+
case "DoWhileStatement":
|
|
3137
|
+
case "ForInStatement":
|
|
3138
|
+
case "ForOfStatement":
|
|
3139
|
+
case "ForStatement":
|
|
3140
|
+
case "WhileStatement":
|
|
3141
|
+
case "ArrowFunctionExpression":
|
|
3142
|
+
case "FunctionDeclaration":
|
|
3143
|
+
case "WithStatement":
|
|
3144
|
+
check(node, parent.type);
|
|
3145
|
+
break;
|
|
3146
|
+
case "FunctionExpression":
|
|
3147
|
+
if (parent.parent.type === "Property" && parent.parent.method) {
|
|
3148
|
+
check(node, "Property");
|
|
3149
|
+
} else {
|
|
3150
|
+
check(node, parent.type);
|
|
3151
|
+
}
|
|
3152
|
+
break;
|
|
3153
|
+
case "IfStatement":
|
|
3154
|
+
if (node === parent.consequent) {
|
|
3155
|
+
check(node, "IfStatementConsequent");
|
|
3156
|
+
}
|
|
3157
|
+
if (node === parent.alternate) {
|
|
3158
|
+
check(node, "IfStatementAlternative");
|
|
3159
|
+
}
|
|
3160
|
+
break;
|
|
3161
|
+
case "TryStatement":
|
|
3162
|
+
if (node === parent.block) {
|
|
3163
|
+
check(node, "TryStatementBlock");
|
|
3164
|
+
}
|
|
3165
|
+
if (node === parent.finalizer) {
|
|
3166
|
+
check(node, "TryStatementFinalizer");
|
|
3167
|
+
}
|
|
3168
|
+
break;
|
|
3169
|
+
case "CatchClause":
|
|
3170
|
+
check(node, "TryStatementHandler");
|
|
3171
|
+
break;
|
|
3172
|
+
default:
|
|
3173
|
+
if (parent.type === "SwitchCase" && parent.consequent.length === 1) {
|
|
3174
|
+
check(node, "SwitchCase");
|
|
3175
|
+
} else {
|
|
3176
|
+
check(node, "BlockStatement");
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
},
|
|
3180
|
+
SwitchStatement: checkBlockLike,
|
|
3181
|
+
ClassBody: checkBlockLike,
|
|
3182
|
+
StaticBlock: checkBlockLike,
|
|
3183
|
+
TSEnumBody: checkBlockLike,
|
|
3184
|
+
TSInterfaceBody: checkBlockLike,
|
|
3185
|
+
TSModuleBlock: checkBlockLike
|
|
3186
|
+
};
|
|
3187
|
+
}
|
|
3188
|
+
});
|
|
3189
|
+
module2.exports = curlyNewline;
|
|
3190
|
+
}
|
|
3191
|
+
});
|
|
3192
|
+
|
|
2909
3193
|
// node_modules/@stylistic/eslint-plugin/dist/rules/dot-location.js
|
|
2910
3194
|
var require_dot_location = __commonJS({
|
|
2911
3195
|
"node_modules/@stylistic/eslint-plugin/dist/rules/dot-location.js"(exports2, module2) {
|
|
@@ -4738,21 +5022,24 @@ var require_indent = __commonJS({
|
|
|
4738
5022
|
const previousQuasi = node.quasis[index2];
|
|
4739
5023
|
const nextQuasi = node.quasis[index2 + 1];
|
|
4740
5024
|
const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line ? sourceCode.getFirstToken(previousQuasi) : null;
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
if (!
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
const numTabs = tokenBeforeText.filter((char) => char === " ").length;
|
|
4748
|
-
indentOffset = numTabs + Math.ceil(numSpaces / (indentType === "tab" ? options.tabLength : indentSize)) + 1;
|
|
4749
|
-
}
|
|
5025
|
+
const startsOnSameLine = previousQuasi.loc.end.line === expression.loc.start.line;
|
|
5026
|
+
const endsOnSameLine = nextQuasi.loc.start.line === expression.loc.end.line;
|
|
5027
|
+
if (tokenToAlignFrom || endsOnSameLine && !startsOnSameLine) {
|
|
5028
|
+
offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1);
|
|
5029
|
+
offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0);
|
|
5030
|
+
return;
|
|
4750
5031
|
}
|
|
4751
|
-
|
|
4752
|
-
|
|
5032
|
+
const tokenBeforeText = sourceCode.text.slice(previousQuasi.range[1] - previousQuasi.loc.end.column, previousQuasi.range[1] - 2).split("");
|
|
5033
|
+
let numIndentation = tokenBeforeText.findIndex((char) => char !== " " && char !== " ");
|
|
5034
|
+
if (numIndentation === -1) {
|
|
5035
|
+
numIndentation = tokenBeforeText.length;
|
|
4753
5036
|
}
|
|
4754
|
-
|
|
4755
|
-
|
|
5037
|
+
const numSpaces = tokenBeforeText.slice(0, numIndentation).filter((char) => char === " ").length;
|
|
5038
|
+
const numTabs = numIndentation - numSpaces;
|
|
5039
|
+
const indentOffset = numTabs + Math.ceil(numSpaces / (indentType === "tab" ? options.tabLength : indentSize));
|
|
5040
|
+
const innerIndentation = endsOnSameLine ? indentOffset : indentOffset + 1;
|
|
5041
|
+
offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, innerIndentation);
|
|
5042
|
+
offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, indentOffset);
|
|
4756
5043
|
});
|
|
4757
5044
|
},
|
|
4758
5045
|
VariableDeclaration(node) {
|
|
@@ -5071,6 +5358,7 @@ ${indent2}${p1}`);
|
|
|
5071
5358
|
// typescript docs and playground use 4 space indent
|
|
5072
5359
|
4,
|
|
5073
5360
|
{
|
|
5361
|
+
// TODO: Stage 2: Set to `0` can pass test cases, but it will change the behavior
|
|
5074
5362
|
// typescript docs indent the case from the switch
|
|
5075
5363
|
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#example-4
|
|
5076
5364
|
SwitchCase: 1,
|
|
@@ -5877,7 +6165,13 @@ var require_jsx_closing_tag_location = __commonJS({
|
|
|
5877
6165
|
require("estraverse");
|
|
5878
6166
|
var messages = {
|
|
5879
6167
|
onOwnLine: "Closing tag of a multiline JSX expression must be on its own line.",
|
|
5880
|
-
matchIndent: "Expected closing tag to match indentation of opening."
|
|
6168
|
+
matchIndent: "Expected closing tag to match indentation of opening.",
|
|
6169
|
+
alignWithOpening: "Expected closing tag to be aligned with the line containing the opening tag"
|
|
6170
|
+
};
|
|
6171
|
+
var DEFAULT_LOCATION = "tag-aligned";
|
|
6172
|
+
var MESSAGE_LOCATION = {
|
|
6173
|
+
"tag-aligned": "matchIndent",
|
|
6174
|
+
"line-aligned": "alignWithOpening"
|
|
5881
6175
|
};
|
|
5882
6176
|
var jsxClosingTagLocation = utils.createRule({
|
|
5883
6177
|
name: "jsx-closing-tag-location",
|
|
@@ -5889,28 +6183,53 @@ var require_jsx_closing_tag_location = __commonJS({
|
|
|
5889
6183
|
},
|
|
5890
6184
|
fixable: "whitespace",
|
|
5891
6185
|
messages,
|
|
5892
|
-
schema: [
|
|
6186
|
+
schema: [{
|
|
6187
|
+
anyOf: [
|
|
6188
|
+
{
|
|
6189
|
+
type: "string",
|
|
6190
|
+
enum: ["tag-aligned", "line-aligned"],
|
|
6191
|
+
default: DEFAULT_LOCATION
|
|
6192
|
+
}
|
|
6193
|
+
]
|
|
6194
|
+
}]
|
|
5893
6195
|
},
|
|
6196
|
+
defaultOptions: [
|
|
6197
|
+
DEFAULT_LOCATION
|
|
6198
|
+
],
|
|
5894
6199
|
create(context) {
|
|
6200
|
+
const option = context.options[0] || DEFAULT_LOCATION;
|
|
6201
|
+
function getIndentation(openingStartOfLine, opening) {
|
|
6202
|
+
if (option === "line-aligned")
|
|
6203
|
+
return openingStartOfLine.column;
|
|
6204
|
+
else
|
|
6205
|
+
return opening.loc.start.column;
|
|
6206
|
+
}
|
|
5895
6207
|
function handleClosingElement(node) {
|
|
5896
6208
|
if (!node.parent)
|
|
5897
6209
|
return;
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
6210
|
+
const sourceCode = context.sourceCode;
|
|
6211
|
+
const opening = "openingFragment" in node.parent ? node.parent.openingFragment : node.parent.openingElement;
|
|
6212
|
+
const openingLoc = sourceCode.getFirstToken(opening).loc.start;
|
|
6213
|
+
const openingLine = sourceCode.lines[openingLoc.line - 1];
|
|
6214
|
+
const openingStartOfLine = {
|
|
6215
|
+
column: /^\s*/.exec(openingLine)?.[0].length,
|
|
6216
|
+
line: openingLoc.line
|
|
6217
|
+
};
|
|
5903
6218
|
if (opening.loc.start.line === node.loc.start.line)
|
|
5904
6219
|
return;
|
|
5905
|
-
if (opening.loc.start.column === node.loc.start.column)
|
|
6220
|
+
if (opening.loc.start.column === node.loc.start.column && option === "tag-aligned") {
|
|
5906
6221
|
return;
|
|
5907
|
-
|
|
6222
|
+
}
|
|
6223
|
+
if (openingStartOfLine.column === node.loc.start.column && option === "line-aligned") {
|
|
6224
|
+
return;
|
|
6225
|
+
}
|
|
6226
|
+
const messageId = utils.isNodeFirstInLine(context, node) ? MESSAGE_LOCATION[option] : "onOwnLine";
|
|
5908
6227
|
context.report({
|
|
5909
6228
|
node,
|
|
5910
6229
|
messageId,
|
|
5911
6230
|
loc: node.loc,
|
|
5912
6231
|
fix(fixer) {
|
|
5913
|
-
const indent = new Array(opening
|
|
6232
|
+
const indent = new Array((getIndentation(openingStartOfLine, opening) || 0) + 1).join(" ");
|
|
5914
6233
|
if (utils.isNodeFirstInLine(context, node)) {
|
|
5915
6234
|
return fixer.replaceTextRange(
|
|
5916
6235
|
[node.range[0] - node.loc.start.column, node.range[0]],
|
|
@@ -13146,7 +13465,7 @@ var require_no_extra_parens = __commonJS({
|
|
|
13146
13465
|
}
|
|
13147
13466
|
});
|
|
13148
13467
|
}
|
|
13149
|
-
if (node.arguments.length === 1 && sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken) !== sourceCode.getTokenBefore(node.arguments[0], astUtils.isOpeningParenToken)) {
|
|
13468
|
+
if (node.typeArguments && node.arguments.length === 1 && sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken) !== sourceCode.getTokenBefore(node.arguments[0], astUtils.isOpeningParenToken)) {
|
|
13150
13469
|
return rule({
|
|
13151
13470
|
...node,
|
|
13152
13471
|
arguments: [
|
|
@@ -13174,20 +13493,11 @@ var require_no_extra_parens = __commonJS({
|
|
|
13174
13493
|
}
|
|
13175
13494
|
const overrides = {
|
|
13176
13495
|
ArrayExpression(node) {
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
...node.elements.slice(0, index2),
|
|
13183
|
-
{
|
|
13184
|
-
...element,
|
|
13185
|
-
type: utils$1.AST_NODE_TYPES.FunctionExpression
|
|
13186
|
-
},
|
|
13187
|
-
...node.elements.slice(index2 + 1)
|
|
13188
|
-
]
|
|
13189
|
-
});
|
|
13190
|
-
}
|
|
13496
|
+
return rules.ArrayExpression({
|
|
13497
|
+
...node,
|
|
13498
|
+
elements: node.elements.map(
|
|
13499
|
+
(element) => astUtils.isTypeAssertion(element) ? { ...element, type: utils$1.AST_NODE_TYPES.FunctionExpression } : element
|
|
13500
|
+
)
|
|
13191
13501
|
});
|
|
13192
13502
|
},
|
|
13193
13503
|
ArrowFunctionExpression(node) {
|
|
@@ -13331,7 +13641,12 @@ var require_no_extra_parens = __commonJS({
|
|
|
13331
13641
|
return rules.ThrowStatement(node);
|
|
13332
13642
|
},
|
|
13333
13643
|
"UnaryExpression": unaryUpdateExpression,
|
|
13334
|
-
|
|
13644
|
+
UpdateExpression(node) {
|
|
13645
|
+
if (astUtils.isTypeAssertion(node.argument)) {
|
|
13646
|
+
return unaryUpdateExpression(node);
|
|
13647
|
+
}
|
|
13648
|
+
return rules.UpdateExpression(node);
|
|
13649
|
+
},
|
|
13335
13650
|
// VariableDeclarator
|
|
13336
13651
|
VariableDeclarator(node) {
|
|
13337
13652
|
if (astUtils.isTypeAssertion(node.init)) {
|
|
@@ -15853,6 +16168,7 @@ var require_padding_line_between_statements = __commonJS({
|
|
|
15853
16168
|
if (!node.parent || ![
|
|
15854
16169
|
utils.AST_NODE_TYPES.BlockStatement,
|
|
15855
16170
|
utils.AST_NODE_TYPES.Program,
|
|
16171
|
+
utils.AST_NODE_TYPES.StaticBlock,
|
|
15856
16172
|
utils.AST_NODE_TYPES.SwitchCase,
|
|
15857
16173
|
utils.AST_NODE_TYPES.SwitchStatement,
|
|
15858
16174
|
utils.AST_NODE_TYPES.TSInterfaceBody,
|
|
@@ -15877,12 +16193,14 @@ var require_padding_line_between_statements = __commonJS({
|
|
|
15877
16193
|
"Program": enterScope,
|
|
15878
16194
|
"BlockStatement": enterScope,
|
|
15879
16195
|
"SwitchStatement": enterScope,
|
|
16196
|
+
"StaticBlock": enterScope,
|
|
15880
16197
|
"TSInterfaceBody": enterScope,
|
|
15881
16198
|
"TSModuleBlock": enterScope,
|
|
15882
16199
|
"TSTypeLiteral": enterScope,
|
|
15883
16200
|
"Program:exit": exitScope,
|
|
15884
16201
|
"BlockStatement:exit": exitScope,
|
|
15885
16202
|
"SwitchStatement:exit": exitScope,
|
|
16203
|
+
"StaticBlock:exit": exitScope,
|
|
15886
16204
|
"TSInterfaceBody:exit": exitScope,
|
|
15887
16205
|
"TSModuleBlock:exit": exitScope,
|
|
15888
16206
|
"TSTypeLiteral:exit": exitScope,
|
|
@@ -16391,7 +16709,7 @@ var require_quotes = __commonJS({
|
|
|
16391
16709
|
if (allowTemplateLiterals || quoteOption === "backtick" || isUsingFeatureOfTemplateLiteral(node)) {
|
|
16392
16710
|
return;
|
|
16393
16711
|
}
|
|
16394
|
-
if (avoidEscape && sourceCode.getText(node).includes(settings.quote))
|
|
16712
|
+
if (allowTemplateLiterals && avoidEscape && sourceCode.getText(node).includes(settings.quote))
|
|
16395
16713
|
return;
|
|
16396
16714
|
context.report({
|
|
16397
16715
|
node,
|
|
@@ -16447,7 +16765,7 @@ var require_quotes = __commonJS({
|
|
|
16447
16765
|
return node === parent.id;
|
|
16448
16766
|
case utils$1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
16449
16767
|
case utils$1.AST_NODE_TYPES.PropertyDefinition:
|
|
16450
|
-
return
|
|
16768
|
+
return parent.key === node && !parent.computed;
|
|
16451
16769
|
case utils$1.AST_NODE_TYPES.TSLiteralType:
|
|
16452
16770
|
return parent.parent?.type === utils$1.AST_NODE_TYPES.TSImportType;
|
|
16453
16771
|
default:
|
|
@@ -17365,8 +17683,8 @@ var require_space_before_function_paren = __commonJS({
|
|
|
17365
17683
|
}
|
|
17366
17684
|
],
|
|
17367
17685
|
messages: {
|
|
17368
|
-
|
|
17369
|
-
|
|
17686
|
+
unexpectedSpace: "Unexpected space before function parentheses.",
|
|
17687
|
+
missingSpace: "Missing space before function parentheses."
|
|
17370
17688
|
}
|
|
17371
17689
|
},
|
|
17372
17690
|
defaultOptions: ["always"],
|
|
@@ -17413,14 +17731,22 @@ var require_space_before_function_paren = __commonJS({
|
|
|
17413
17731
|
start: leftToken.loc.end,
|
|
17414
17732
|
end: rightToken.loc.start
|
|
17415
17733
|
},
|
|
17416
|
-
messageId: "
|
|
17417
|
-
fix: (fixer) =>
|
|
17734
|
+
messageId: "unexpectedSpace",
|
|
17735
|
+
fix: (fixer) => {
|
|
17736
|
+
const comments = sourceCode.getCommentsBefore(rightToken);
|
|
17737
|
+
if (comments.some((comment) => comment.type === "Line"))
|
|
17738
|
+
return null;
|
|
17739
|
+
return fixer.replaceTextRange(
|
|
17740
|
+
[leftToken.range[1], rightToken.range[0]],
|
|
17741
|
+
comments.reduce((text, comment) => text + sourceCode.getText(comment), "")
|
|
17742
|
+
);
|
|
17743
|
+
}
|
|
17418
17744
|
});
|
|
17419
17745
|
} else if (!hasSpacing && functionConfig === "always" && (!node.typeParameters || node.id)) {
|
|
17420
17746
|
context.report({
|
|
17421
17747
|
node,
|
|
17422
17748
|
loc: rightToken.loc,
|
|
17423
|
-
messageId: "
|
|
17749
|
+
messageId: "missingSpace",
|
|
17424
17750
|
fix: (fixer) => fixer.insertTextAfter(leftToken, " ")
|
|
17425
17751
|
});
|
|
17426
17752
|
}
|
|
@@ -17729,6 +18055,7 @@ var require_space_infix_ops = __commonJS({
|
|
|
17729
18055
|
LogicalExpression: checkBinary,
|
|
17730
18056
|
ConditionalExpression: checkConditional,
|
|
17731
18057
|
VariableDeclarator: checkVar,
|
|
18058
|
+
// TODO: Stage 3: Overridden by ts version, can delete directly
|
|
17732
18059
|
PropertyDefinition(node) {
|
|
17733
18060
|
if (!node.value)
|
|
17734
18061
|
return;
|
|
@@ -17765,9 +18092,10 @@ var require_space_infix_ops = __commonJS({
|
|
|
17765
18092
|
create(context) {
|
|
17766
18093
|
const rules = baseRule.create(context);
|
|
17767
18094
|
const sourceCode = context.sourceCode;
|
|
17768
|
-
function report(operator) {
|
|
18095
|
+
function report(node, operator) {
|
|
17769
18096
|
context.report({
|
|
17770
|
-
node
|
|
18097
|
+
node,
|
|
18098
|
+
loc: operator.loc,
|
|
17771
18099
|
messageId: "missingSpace",
|
|
17772
18100
|
data: {
|
|
17773
18101
|
operator: operator.value
|
|
@@ -17788,7 +18116,7 @@ var require_space_infix_ops = __commonJS({
|
|
|
17788
18116
|
function isSpaceChar(token) {
|
|
17789
18117
|
return token.type === utils$1.AST_TOKEN_TYPES.Punctuator && /^[=?:]$/.test(token.value);
|
|
17790
18118
|
}
|
|
17791
|
-
function checkAndReportAssignmentSpace(leftNode, rightNode) {
|
|
18119
|
+
function checkAndReportAssignmentSpace(node, leftNode, rightNode) {
|
|
17792
18120
|
if (!rightNode || !leftNode)
|
|
17793
18121
|
return;
|
|
17794
18122
|
const operator = sourceCode.getFirstTokenBetween(
|
|
@@ -17799,15 +18127,15 @@ var require_space_infix_ops = __commonJS({
|
|
|
17799
18127
|
const prev = sourceCode.getTokenBefore(operator);
|
|
17800
18128
|
const next = sourceCode.getTokenAfter(operator);
|
|
17801
18129
|
if (!sourceCode.isSpaceBetween(prev, operator) || !sourceCode.isSpaceBetween(operator, next)) {
|
|
17802
|
-
report(operator);
|
|
18130
|
+
report(node, operator);
|
|
17803
18131
|
}
|
|
17804
18132
|
}
|
|
17805
18133
|
function checkForEnumAssignmentSpace(node) {
|
|
17806
|
-
checkAndReportAssignmentSpace(node.id, node.initializer);
|
|
18134
|
+
checkAndReportAssignmentSpace(node, node.id, node.initializer);
|
|
17807
18135
|
}
|
|
17808
18136
|
function checkForPropertyDefinitionAssignmentSpace(node) {
|
|
17809
18137
|
const leftNode = node.optional && !node.typeAnnotation ? sourceCode.getTokenAfter(node.key) : node.typeAnnotation ?? node.key;
|
|
17810
|
-
checkAndReportAssignmentSpace(leftNode, node.value);
|
|
18138
|
+
checkAndReportAssignmentSpace(node, leftNode, node.value);
|
|
17811
18139
|
}
|
|
17812
18140
|
function checkForTypeAnnotationSpace(typeAnnotation) {
|
|
17813
18141
|
const types = typeAnnotation.types;
|
|
@@ -17821,20 +18149,21 @@ var require_space_infix_ops = __commonJS({
|
|
|
17821
18149
|
const prev = sourceCode.getTokenBefore(operator);
|
|
17822
18150
|
const next = sourceCode.getTokenAfter(operator);
|
|
17823
18151
|
if (!sourceCode.isSpaceBetween(prev, operator) || !sourceCode.isSpaceBetween(operator, next)) {
|
|
17824
|
-
report(operator);
|
|
18152
|
+
report(typeAnnotation, operator);
|
|
17825
18153
|
}
|
|
17826
18154
|
}
|
|
17827
18155
|
});
|
|
17828
18156
|
}
|
|
17829
18157
|
function checkForTypeAliasAssignment(node) {
|
|
17830
18158
|
checkAndReportAssignmentSpace(
|
|
18159
|
+
node,
|
|
17831
18160
|
node.typeParameters ?? node.id,
|
|
17832
18161
|
node.typeAnnotation
|
|
17833
18162
|
);
|
|
17834
18163
|
}
|
|
17835
18164
|
function checkForTypeConditional(node) {
|
|
17836
|
-
checkAndReportAssignmentSpace(node.extendsType, node.trueType);
|
|
17837
|
-
checkAndReportAssignmentSpace(node.trueType, node.falseType);
|
|
18165
|
+
checkAndReportAssignmentSpace(node, node.extendsType, node.trueType);
|
|
18166
|
+
checkAndReportAssignmentSpace(node, node.trueType, node.falseType);
|
|
17838
18167
|
}
|
|
17839
18168
|
return {
|
|
17840
18169
|
...rules,
|
|
@@ -19257,6 +19586,7 @@ var require_configs = __commonJS({
|
|
|
19257
19586
|
var commaSpacing = require_comma_spacing();
|
|
19258
19587
|
var commaStyle = require_comma_style();
|
|
19259
19588
|
var computedPropertySpacing = require_computed_property_spacing();
|
|
19589
|
+
var curlyNewline = require_curly_newline();
|
|
19260
19590
|
var dotLocation = require_dot_location();
|
|
19261
19591
|
var eolLast = require_eol_last();
|
|
19262
19592
|
var functionCallArgumentNewline = require_function_call_argument_newline();
|
|
@@ -19352,6 +19682,7 @@ var require_configs = __commonJS({
|
|
|
19352
19682
|
"comma-spacing": commaSpacing,
|
|
19353
19683
|
"comma-style": commaStyle,
|
|
19354
19684
|
"computed-property-spacing": computedPropertySpacing,
|
|
19685
|
+
"curly-newline": curlyNewline,
|
|
19355
19686
|
"dot-location": dotLocation,
|
|
19356
19687
|
"eol-last": eolLast,
|
|
19357
19688
|
"func-call-spacing": functionCallSpacing,
|
|
@@ -19486,6 +19817,7 @@ var require_configs = __commonJS({
|
|
|
19486
19817
|
offsetTernaryExpressions: true,
|
|
19487
19818
|
outerIIFEBody: 1,
|
|
19488
19819
|
SwitchCase: 1,
|
|
19820
|
+
tabLength: indent2 === "tab" ? 4 : indent2,
|
|
19489
19821
|
VariableDeclarator: 1
|
|
19490
19822
|
}],
|
|
19491
19823
|
"@stylistic/indent-binary-ops": ["error", indent2],
|
|
@@ -19733,6 +20065,12 @@ var require_configs = __commonJS({
|
|
|
19733
20065
|
}
|
|
19734
20066
|
};
|
|
19735
20067
|
var recommendedExtends = /* @__PURE__ */ customize({ flat: false });
|
|
20068
|
+
var allConfigsIgnore = [
|
|
20069
|
+
// Exclude all JSX rules
|
|
20070
|
+
/^jsx-/,
|
|
20071
|
+
// https://github.com/eslint-stylistic/eslint-stylistic/pull/548
|
|
20072
|
+
/^curly-newline$/
|
|
20073
|
+
];
|
|
19736
20074
|
var configs2 = {
|
|
19737
20075
|
/**
|
|
19738
20076
|
* Disable all legacy rules from `eslint`, `@typescript-eslint` and `eslint-plugin-react`
|
|
@@ -19755,11 +20093,11 @@ var require_configs = __commonJS({
|
|
|
19755
20093
|
/**
|
|
19756
20094
|
* Enable all rules, in Flat Config Format
|
|
19757
20095
|
*/
|
|
19758
|
-
"all-flat": utils.createAllConfigs(plugin, "@stylistic", true, (name) => !
|
|
20096
|
+
"all-flat": utils.createAllConfigs(plugin, "@stylistic", true, (name) => !allConfigsIgnore.some((re) => re.test(name))),
|
|
19759
20097
|
/**
|
|
19760
20098
|
* Enable all rules, in Legacy Config Format
|
|
19761
20099
|
*/
|
|
19762
|
-
"all-extends": utils.createAllConfigs(plugin, "@stylistic", false, (name) => !
|
|
20100
|
+
"all-extends": utils.createAllConfigs(plugin, "@stylistic", false, (name) => !allConfigsIgnore.some((re) => re.test(name))),
|
|
19763
20101
|
/**
|
|
19764
20102
|
* @deprecated Use `recommended-extends` instead
|
|
19765
20103
|
*/
|
|
@@ -19789,6 +20127,7 @@ require_comma_dangle();
|
|
|
19789
20127
|
require_comma_spacing();
|
|
19790
20128
|
require_comma_style();
|
|
19791
20129
|
require_computed_property_spacing();
|
|
20130
|
+
require_curly_newline();
|
|
19792
20131
|
require_dot_location();
|
|
19793
20132
|
require_eol_last();
|
|
19794
20133
|
require_function_call_argument_newline();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/eslint-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
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.12.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"*.md",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/plugjs/eslint-plugin#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@eslint/js": "9.
|
|
38
|
+
"@eslint/js": "9.12.0",
|
|
39
39
|
"@nolyfill/is-core-module": "1.0.39",
|
|
40
|
-
"@typescript-eslint/utils": "8.8.
|
|
40
|
+
"@typescript-eslint/utils": "8.8.1",
|
|
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.12.0",
|
|
45
45
|
"eslint-module-utils": "2.12.0",
|
|
46
46
|
"eslint-plugin-unicorn": "56.0.0",
|
|
47
47
|
"eslint-visitor-keys": "4.1.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
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.11.0",
|
|
53
53
|
"is-bun-module": "1.2.1",
|
|
54
54
|
"is-core-module": "2.15.1",
|
|
55
55
|
"is-glob": "4.0.3",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"semver": "7.6.3",
|
|
60
60
|
"stable-hash": "0.0.4",
|
|
61
61
|
"tslib": "2.7.0",
|
|
62
|
-
"typescript": "5.6.
|
|
63
|
-
"typescript-eslint": "8.8.
|
|
62
|
+
"typescript": "5.6.3",
|
|
63
|
+
"typescript-eslint": "8.8.1"
|
|
64
64
|
}
|
|
65
65
|
}
|