google_forms/node_modules/eslint/lib/rules/no-async-promise-executor.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-08-09 12:04:48 +00:00
/**
* @fileoverview disallow using an async function as a Promise executor
* @author Teddy Katz
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
2024-08-21 06:34:30 +00:00
/** @type {import('../shared/types').Rule} */
2024-08-09 12:04:48 +00:00
module.exports = {
meta: {
type: "problem",
docs: {
2024-08-21 06:34:30 +00:00
description: "Disallow using an async function as a Promise executor",
2024-08-09 12:04:48 +00:00
recommended: true,
2024-08-21 06:34:30 +00:00
url: "https://eslint.org/docs/latest/rules/no-async-promise-executor"
2024-08-09 12:04:48 +00:00
},
fixable: null,
schema: [],
messages: {
async: "Promise executor functions should not be async."
}
},
create(context) {
return {
"NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
context.report({
2024-08-21 06:34:30 +00:00
node: context.sourceCode.getFirstToken(node.arguments[0], token => token.value === "async"),
2024-08-09 12:04:48 +00:00
messageId: "async"
});
}
};
}
};