@so1ve/eslint-plugin 0.47.3 → 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 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 (textBetweenFunctionNameAndParen.value.length > 0 && textBetweenFunctionNameAndParen.value !== "?.") {
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 (textBetweenFunctionNameAndParen.value.length > 0 && textBetweenFunctionNameAndParen.value !== "?.") {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "0.47.3",
3
+ "version": "0.48.0",
4
4
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
5
5
  "contributors": [
6
6
  {