Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-async-promise-executor.js 1.0KB

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