@so1ve/eslint-plugin 0.110.2 → 0.110.4

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
@@ -522,10 +522,12 @@ const useAsyncWithAwait = createEslintRule({
522
522
  if (!closestFunctionNode || closestFunctionNode.async) {
523
523
  return;
524
524
  }
525
+ const node = closestFunctionNode.type === types.TSESTree.AST_NODE_TYPES.FunctionExpression && closestFunctionNode.parent?.type === types.TSESTree.AST_NODE_TYPES.MethodDefinition ? closestFunctionNode.parent : closestFunctionNode;
526
+ const fixRange = node.type === types.TSESTree.AST_NODE_TYPES.MethodDefinition ? node.key.range : node.range;
525
527
  context.report({
526
- node: closestFunctionNode,
528
+ node,
527
529
  messageId: "useAsyncWithAwait",
528
- fix: (fixer) => fixer.insertTextBefore(closestFunctionNode, "async ")
530
+ fix: (fixer) => fixer.insertTextBeforeRange(fixRange, "async ")
529
531
  });
530
532
  }
531
533
  };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { AST_NODE_TYPES } from '@typescript-eslint/types';
1
+ import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types';
2
2
  import { ESLintUtils } from '@typescript-eslint/utils';
3
3
 
4
4
  const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
@@ -520,10 +520,12 @@ const useAsyncWithAwait = createEslintRule({
520
520
  if (!closestFunctionNode || closestFunctionNode.async) {
521
521
  return;
522
522
  }
523
+ const node = closestFunctionNode.type === TSESTree.AST_NODE_TYPES.FunctionExpression && closestFunctionNode.parent?.type === TSESTree.AST_NODE_TYPES.MethodDefinition ? closestFunctionNode.parent : closestFunctionNode;
524
+ const fixRange = node.type === TSESTree.AST_NODE_TYPES.MethodDefinition ? node.key.range : node.range;
523
525
  context.report({
524
- node: closestFunctionNode,
526
+ node,
525
527
  messageId: "useAsyncWithAwait",
526
- fix: (fixer) => fixer.insertTextBefore(closestFunctionNode, "async ")
528
+ fix: (fixer) => fixer.insertTextBeforeRange(fixRange, "async ")
527
529
  });
528
530
  }
529
531
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "0.110.2",
3
+ "version": "0.110.4",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "keywords": [
6
6
  "eslint",