@so1ve/eslint-plugin 0.47.2 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -2
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -470,13 +470,15 @@ const noSpaceBeforeParen = createEslintRule({
|
|
|
470
470
|
if (node.optional) {
|
|
471
471
|
parenStart.value = callerEnd.value + textAfterCaller.value.indexOf("(");
|
|
472
472
|
}
|
|
473
|
+
const spaces = /(\s*)$/.exec(textBetweenFunctionNameAndParen.value)[1];
|
|
473
474
|
if (!hasGenerics.value) {
|
|
474
|
-
if (
|
|
475
|
+
if (spaces.length > 0 && textBetweenFunctionNameAndParen.value !== "?.") {
|
|
476
|
+
const textBeforeSpaces = textBetweenFunctionNameAndParen.value.slice(0, textBetweenFunctionNameAndParen.value.length - spaces.length);
|
|
475
477
|
context.report({
|
|
476
478
|
node,
|
|
477
479
|
messageId: "noSpaceBeforeParen",
|
|
478
480
|
*fix(fixer) {
|
|
479
|
-
yield fixer.replaceTextRange(textBetweenFunctionNameAndParenRange.value, node.optional ? "?." : "");
|
|
481
|
+
yield fixer.replaceTextRange(textBetweenFunctionNameAndParenRange.value, textBeforeSpaces + (node.optional ? "?." : ""));
|
|
480
482
|
}
|
|
481
483
|
});
|
|
482
484
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -455,13 +455,15 @@ const noSpaceBeforeParen = createEslintRule({
|
|
|
455
455
|
if (node.optional) {
|
|
456
456
|
parenStart.value = callerEnd.value + textAfterCaller.value.indexOf("(");
|
|
457
457
|
}
|
|
458
|
+
const spaces = /(\s*)$/.exec(textBetweenFunctionNameAndParen.value)[1];
|
|
458
459
|
if (!hasGenerics.value) {
|
|
459
|
-
if (
|
|
460
|
+
if (spaces.length > 0 && textBetweenFunctionNameAndParen.value !== "?.") {
|
|
461
|
+
const textBeforeSpaces = textBetweenFunctionNameAndParen.value.slice(0, textBetweenFunctionNameAndParen.value.length - spaces.length);
|
|
460
462
|
context.report({
|
|
461
463
|
node,
|
|
462
464
|
messageId: "noSpaceBeforeParen",
|
|
463
465
|
*fix(fixer) {
|
|
464
|
-
yield fixer.replaceTextRange(textBetweenFunctionNameAndParenRange.value, node.optional ? "?." : "");
|
|
466
|
+
yield fixer.replaceTextRange(textBetweenFunctionNameAndParenRange.value, textBeforeSpaces + (node.optional ? "?." : ""));
|
|
465
467
|
}
|
|
466
468
|
});
|
|
467
469
|
}
|