@so1ve/eslint-plugin 0.110.2 → 0.110.3
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 +5 -3
- package/package.json +1 -1
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
|
|
528
|
+
node,
|
|
527
529
|
messageId: "useAsyncWithAwait",
|
|
528
|
-
fix: (fixer) => fixer.
|
|
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
|
|
526
|
+
node,
|
|
525
527
|
messageId: "useAsyncWithAwait",
|
|
526
|
-
fix: (fixer) => fixer.
|
|
528
|
+
fix: (fixer) => fixer.insertTextBeforeRange(fixRange, "async ")
|
|
527
529
|
});
|
|
528
530
|
}
|
|
529
531
|
};
|