]> git.proxmox.com Git - pve-eslint.git/blame - eslint/lib/rules/no-async-promise-executor.js
import 8.23.1 source
[pve-eslint.git] / eslint / lib / rules / no-async-promise-executor.js
CommitLineData
eb39fafa
DC
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
34eeec05 11/** @type {import('../shared/types').Rule} */
eb39fafa
DC
12module.exports = {
13 meta: {
14 type: "problem",
15
16 docs: {
8f9d1d4d 17 description: "Disallow using an async function as a Promise executor",
eb39fafa
DC
18 recommended: true,
19 url: "https://eslint.org/docs/rules/no-async-promise-executor"
20 },
21
22 fixable: null,
23 schema: [],
24 messages: {
25 async: "Promise executor functions should not be async."
26 }
27 },
28
29 create(context) {
30 return {
31 "NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
32 context.report({
33 node: context.getSourceCode().getFirstToken(node.arguments[0], token => token.value === "async"),
34 messageId: "async"
35 });
36 }
37 };
38 }
39};