UNPKG

eslint-plugin-mocha

Version:

Eslint rules for mocha.

35 lines 1.23 kB
import { createMochaVisitors } from "../ast/mocha-visitors.js"; import { isFunction } from "../ast/node-types.js"; import { hasCallbackParameter } from "../mocha/callback-parameter.js"; function checkNodeForAsyncAndDone(context, node) { if (!isFunction(node) || node.async !== true || !hasCallbackParameter(node)) { return; } context.report({ node, messageId: 'unexpectedAsyncAndDone' }); } export const noAsyncAndDoneRule = { meta: { type: 'problem', docs: { description: 'Disallow async functions that also use a Mocha callback', recommended: true, url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/documentation/rules/no-async-and-done.md' }, schema: [], messages: { unexpectedAsyncAndDone: 'Do not use an async function together with a Mocha callback parameter' }, languages: ['js/js'] }, create(context) { return createMochaVisitors(context, { anyTestEntityCallback(visitorContext) { checkNodeForAsyncAndDone(context, visitorContext.node); } }); } }; //# sourceMappingURL=no-async-and-done.js.map