UNPKG

eslint-plugin-mocha

Version:

Eslint rules for mocha.

20 lines 894 B
import { getParentNode, isFunction, isMemberExpression } from "../ast/node-types.js"; function isNestedStatementBoundary(node) { return node.type.endsWith('Statement') || node.type.endsWith('Declaration') || isFunction(node); } export function isDirectStatementInScope(scopeNode, node) { let current = node; while (!Object.is(getParentNode(current), scopeNode)) { current = getParentNode(current); if (isNestedStatementBoundary(current) && !(current.type === 'ExpressionStatement' && Object.is(getParentNode(current), scopeNode))) { return false; } } return current.type === 'ExpressionStatement'; } export function getTopLevelMochaExpression(node) { const parent = getParentNode(node); return isMemberExpression(parent) ? getTopLevelMochaExpression(parent) : node; } //# sourceMappingURL=direct-mocha-statement.js.map