]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-async-promise-executor.js
27116f1da788e78ab6705c11759a59022cc1c221
[pve-eslint.git] / eslint / lib / rules / no-async-promise-executor.js
1 /**
2 * @fileoverview disallow using an async function as a Promise executor
3 * @author Teddy Katz
4 */
5 "use strict";
6
7 //------------------------------------------------------------------------------
8 // Rule Definition
9 //------------------------------------------------------------------------------
10
11 module.exports = {
12 meta: {
13 type: "problem",
14
15 docs: {
16 description: "disallow using an async function as a Promise executor",
17 recommended: true,
18 url: "https://eslint.org/docs/rules/no-async-promise-executor"
19 },
20
21 fixable: null,
22 schema: [],
23 messages: {
24 async: "Promise executor functions should not be async."
25 }
26 },
27
28 create(context) {
29 return {
30 "NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
31 context.report({
32 node: context.getSourceCode().getFirstToken(node.arguments[0], token => token.value === "async"),
33 messageId: "async"
34 });
35 }
36 };
37 }
38 };