@so1ve/eslint-plugin 0.108.0 → 0.108.2
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 +16 -40
- package/dist/index.mjs +16 -40
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -503,54 +503,30 @@ const useAsyncWithAwait = createEslintRule({
|
|
|
503
503
|
},
|
|
504
504
|
defaultOptions: [],
|
|
505
505
|
create: (context) => {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
scopeStack.push(context.getScope());
|
|
506
|
+
const functionNodeScopeStack = [];
|
|
507
|
+
function setupNode(node) {
|
|
508
|
+
functionNodeScopeStack.push(node);
|
|
510
509
|
}
|
|
511
|
-
function
|
|
512
|
-
|
|
513
|
-
haveAwaitExpression = false;
|
|
510
|
+
function clearNode() {
|
|
511
|
+
functionNodeScopeStack.pop();
|
|
514
512
|
}
|
|
515
513
|
return {
|
|
516
|
-
"FunctionExpression
|
|
517
|
-
"FunctionExpression
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
});
|
|
526
|
-
clearAwaitExpression();
|
|
527
|
-
},
|
|
528
|
-
"FunctionDeclaration[async=false]": setupScope,
|
|
529
|
-
"FunctionDeclaration[async=false]:exit"(node) {
|
|
530
|
-
if (!haveAwaitExpression) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
context.report({
|
|
534
|
-
node,
|
|
535
|
-
messageId: "useAsyncWithAwait",
|
|
536
|
-
fix: (fixer) => fixer.insertTextBefore(node, "async ")
|
|
537
|
-
});
|
|
538
|
-
clearAwaitExpression();
|
|
539
|
-
},
|
|
540
|
-
"ArrowFunctionExpression[async=false]": setupScope,
|
|
541
|
-
"ArrowFunctionExpression[async=false]:exit"(node) {
|
|
542
|
-
if (!haveAwaitExpression) {
|
|
514
|
+
"FunctionExpression": setupNode,
|
|
515
|
+
"FunctionExpression:exit": clearNode,
|
|
516
|
+
"FunctionDeclaration": setupNode,
|
|
517
|
+
"FunctionDeclaration:exit": clearNode,
|
|
518
|
+
"ArrowFunctionExpression": setupNode,
|
|
519
|
+
"ArrowFunctionExpression:exit": clearNode,
|
|
520
|
+
AwaitExpression() {
|
|
521
|
+
const closestFunctionNode = functionNodeScopeStack[functionNodeScopeStack.length - 1];
|
|
522
|
+
if (!closestFunctionNode || closestFunctionNode.async) {
|
|
543
523
|
return;
|
|
544
524
|
}
|
|
545
525
|
context.report({
|
|
546
|
-
node,
|
|
526
|
+
node: closestFunctionNode,
|
|
547
527
|
messageId: "useAsyncWithAwait",
|
|
548
|
-
fix: (fixer) => fixer.insertTextBefore(
|
|
528
|
+
fix: (fixer) => fixer.insertTextBefore(closestFunctionNode, "async ")
|
|
549
529
|
});
|
|
550
|
-
clearAwaitExpression();
|
|
551
|
-
},
|
|
552
|
-
AwaitExpression() {
|
|
553
|
-
haveAwaitExpression = scopeStack.includes(context.getScope());
|
|
554
530
|
}
|
|
555
531
|
};
|
|
556
532
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -501,54 +501,30 @@ const useAsyncWithAwait = createEslintRule({
|
|
|
501
501
|
},
|
|
502
502
|
defaultOptions: [],
|
|
503
503
|
create: (context) => {
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
scopeStack.push(context.getScope());
|
|
504
|
+
const functionNodeScopeStack = [];
|
|
505
|
+
function setupNode(node) {
|
|
506
|
+
functionNodeScopeStack.push(node);
|
|
508
507
|
}
|
|
509
|
-
function
|
|
510
|
-
|
|
511
|
-
haveAwaitExpression = false;
|
|
508
|
+
function clearNode() {
|
|
509
|
+
functionNodeScopeStack.pop();
|
|
512
510
|
}
|
|
513
511
|
return {
|
|
514
|
-
"FunctionExpression
|
|
515
|
-
"FunctionExpression
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
});
|
|
524
|
-
clearAwaitExpression();
|
|
525
|
-
},
|
|
526
|
-
"FunctionDeclaration[async=false]": setupScope,
|
|
527
|
-
"FunctionDeclaration[async=false]:exit"(node) {
|
|
528
|
-
if (!haveAwaitExpression) {
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
context.report({
|
|
532
|
-
node,
|
|
533
|
-
messageId: "useAsyncWithAwait",
|
|
534
|
-
fix: (fixer) => fixer.insertTextBefore(node, "async ")
|
|
535
|
-
});
|
|
536
|
-
clearAwaitExpression();
|
|
537
|
-
},
|
|
538
|
-
"ArrowFunctionExpression[async=false]": setupScope,
|
|
539
|
-
"ArrowFunctionExpression[async=false]:exit"(node) {
|
|
540
|
-
if (!haveAwaitExpression) {
|
|
512
|
+
"FunctionExpression": setupNode,
|
|
513
|
+
"FunctionExpression:exit": clearNode,
|
|
514
|
+
"FunctionDeclaration": setupNode,
|
|
515
|
+
"FunctionDeclaration:exit": clearNode,
|
|
516
|
+
"ArrowFunctionExpression": setupNode,
|
|
517
|
+
"ArrowFunctionExpression:exit": clearNode,
|
|
518
|
+
AwaitExpression() {
|
|
519
|
+
const closestFunctionNode = functionNodeScopeStack[functionNodeScopeStack.length - 1];
|
|
520
|
+
if (!closestFunctionNode || closestFunctionNode.async) {
|
|
541
521
|
return;
|
|
542
522
|
}
|
|
543
523
|
context.report({
|
|
544
|
-
node,
|
|
524
|
+
node: closestFunctionNode,
|
|
545
525
|
messageId: "useAsyncWithAwait",
|
|
546
|
-
fix: (fixer) => fixer.insertTextBefore(
|
|
526
|
+
fix: (fixer) => fixer.insertTextBefore(closestFunctionNode, "async ")
|
|
547
527
|
});
|
|
548
|
-
clearAwaitExpression();
|
|
549
|
-
},
|
|
550
|
-
AwaitExpression() {
|
|
551
|
-
haveAwaitExpression = scopeStack.includes(context.getScope());
|
|
552
528
|
}
|
|
553
529
|
};
|
|
554
530
|
}
|