UNPKG

eslint-plugin-mocha

Version:

Eslint rules for mocha.

61 lines 3.55 kB
import type { Rule } from 'eslint'; import type { Except } from 'type-fest'; import type { MochaConfigCall, MochaEntityType, MochaInterface, MochaModifier } from '../mocha/descriptors.ts'; import { type AnyFunctionExpressionNode } from './function-expression-arguments.ts'; type MochaVisitor = (context: Readonly<VisitorContext>) => void; type MochaCallbackVisitor = (context: Readonly<CallbackVisitorContext>) => void; type TestEntityVisitors = { readonly config?: MochaVisitor | undefined; readonly 'config:exit'?: MochaVisitor | undefined; readonly testCase?: MochaVisitor | undefined; readonly 'testCase:exit'?: MochaVisitor | undefined; readonly testCaseCallback?: MochaCallbackVisitor | undefined; readonly 'testCaseCallback:exit'?: MochaCallbackVisitor | undefined; readonly suite?: MochaVisitor | undefined; readonly 'suite:exit'?: MochaVisitor | undefined; readonly suiteCallback?: MochaCallbackVisitor | undefined; readonly 'suiteCallback:exit'?: MochaCallbackVisitor | undefined; readonly hook?: MochaVisitor | undefined; readonly 'hook:exit'?: MochaVisitor | undefined; readonly hookCallback?: MochaCallbackVisitor | undefined; readonly 'hookCallback:exit'?: MochaCallbackVisitor | undefined; readonly suiteOrTestCase?: MochaVisitor | undefined; readonly 'suiteOrTestCase:exit'?: MochaVisitor | undefined; readonly anyTestEntity?: MochaVisitor | undefined; readonly 'anyTestEntity:exit'?: MochaVisitor | undefined; readonly anyTestEntityCallback?: MochaCallbackVisitor | undefined; readonly 'anyTestEntityCallback:exit'?: MochaCallbackVisitor | undefined; }; type MochaSpecificVisitors = TestEntityVisitors & { readonly nonMochaCallExpression?: Rule.RuleListener['CallExpression']; readonly 'nonMochaCallExpression:exit'?: Rule.RuleListener['CallExpression:exit']; readonly mochaMemberExpression?: Rule.RuleListener['MemberExpression']; readonly nonMochaMemberExpression?: Rule.RuleListener['MemberExpression']; readonly 'mochaMemberExpression:exit'?: Rule.RuleListener['MemberExpression:exit']; readonly 'nonMochaMemberExpression:exit'?: Rule.RuleListener['MemberExpression:exit']; readonly mochaFunctionExpression?: Rule.RuleListener['FunctionExpression']; readonly nonMochaFunctionExpression?: Rule.RuleListener['FunctionExpression']; readonly 'mochaFunctionExpression:exit'?: Rule.RuleListener['FunctionExpression:exit']; readonly 'nonMochaFunctionExpression:exit'?: Rule.RuleListener['FunctionExpression:exit']; }; type RemoveIndex<T> = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K]; }; type MochaVisitors = Readonly<MochaSpecificVisitors & Record<`${string},${string}`, (node: Readonly<Rule.Node>) => void> & RemoveIndex<Rule.RuleListener>>; export type VisitorContext = { readonly name: string; readonly node: Rule.Node; readonly type: MochaEntityType; readonly config: MochaConfigCall | null; readonly modifier: MochaModifier | null; readonly interface: MochaInterface; }; type CallbackVisitorContext = Except<VisitorContext, 'node'> & { readonly node: AnyFunctionExpressionNode; }; type CreateMochaVisitorOptions = { readonly includeAllInterfaces?: boolean; }; export declare function createMochaVisitors(context: Readonly<Rule.RuleContext>, visitors: Readonly<MochaVisitors>, options?: Readonly<CreateMochaVisitorOptions>): Readonly<Rule.RuleListener>; export {}; //# sourceMappingURL=mocha-visitors.d.ts.map