TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mpsuesser/effect-oxlint/llms.txt
Use this file to discover all available pages before exploring further.
Testing module is a dedicated subpath export (effect-oxlint/testing) that provides everything you need to test Effect-first oxlint rules without a real oxlint process. It includes runners that execute a rule against a single mock AST node, assertion helpers that produce readable errors on mismatch, a mock RuleContext factory for it.effect tests, and a large set of AST node builders that produce structurally correct mock nodes without any file parsing.
Rule runners
Testing.runRule
Runs a rule with a single visitor event and returns the collected diagnostics.
The rule creator returned by
Rule.define.The visitor key to fire (e.g.,
"ThrowStatement", "CallExpression").The AST node to pass to the visitor handler. Use any of the node builders in this module.
Optional mock context options. See
MockContextOptions below.All diagnostics reported by the rule during this visitor call.
Testing.runRuleMulti
Runs a rule with multiple visitor/node pairs sequentially on a shared context. Use this when your rule tracks state across multiple visitor calls.
The rule creator returned by
Rule.define.An array of
[visitorKey, node] tuples. The rule’s create function is called once, and each pair is dispatched in order to the same visitor object.Optional mock context options.
All diagnostics reported across all visitor calls.
Assertion helpers
Testing.expectDiagnostics
Asserts that the diagnostics in result match expected. Each matcher is checked partially — only provided fields (message or messageId) are compared, so you do not need to specify every field on a diagnostic.
The result returned by
runRule or runRuleMulti.The expected diagnostic patterns. Order must match the order diagnostics were reported.
Testing.expectNoDiagnostics
Asserts that no diagnostics were reported. Throws an error listing all actual diagnostics if any exist.
The result returned by
runRule or runRuleMulti.Testing.messages
Extracts the diagnostic messages from a result array. Returns Option.some(message) for diagnostics that use message, and Option.none() for diagnostics that use messageId or have a null message.
The result returned by
runRule or runRuleMulti.One
Option<string> per diagnostic.Testing.messageIds
Extracts the diagnostic messageId values from a result array. Returns Option.some(messageId) for diagnostics that use messageId, and Option.none() for those that use message or have a null messageId.
The result returned by
runRule or runRuleMulti.One
Option<string> per diagnostic.Mock context
Testing.createMockContext
Creates a mock oxlint Context object and a mutable diagnostics array. The mock provides the minimal surface required by fromOxlintContext in RuleContext.
Optional configuration for the mock context. All fields are optional.
A fully-shaped mock
Context object with stubbed sourceCode methods and the provided options applied.A mutable array that collects every
report() call made through context.report.MockContextOptions
The mock filename. Defaults to
"/test/file.ts".The mock current working directory. Defaults to
"/test".Rule options array, as passed via oxlint config. Defaults to
[].The mock source text returned by
sourceCode.getText(). Defaults to "".Comments returned by
sourceCode.getAllComments(). Defaults to [].Testing.mockRuleContextLayer
Creates an Effect Layer that provides a mock RuleContext service. Use this in it.effect tests that need to yield* visitor handlers (which have RuleContext in their requirements).
Optional mock context options passed to
createMockContext.A layer that provides the
RuleContext service backed by the mock context.Testing.withMockRuleContext
Provides a mock RuleContext to an effect without explicitly constructing a layer.
An effect that requires
RuleContext.Optional mock context options.
The same effect with
RuleContext satisfied by a mock instance.AST node builders
All builders return fully-shaped mock AST node objects that satisfy the type shapes expected by theAST, Visitor, and Rule modules. Pass them directly to runRule or runRuleMulti.
Identifiers and member expressions
Identifiers and member expressions
Testing.id — Identifier: { type: "Identifier", name }Testing.memberExpr — MemberExpression: obj.prop (non-computed)Testing.computedMemberExpr — MemberExpression: obj[prop] (computed)Testing.chainedMemberExpr — Chained MemberExpression: a.b.cCall and new expressions
Call and new expressions
Testing.callExpr — CallExpression with bare identifier callee: name(args)Testing.callOfMember — CallExpression with MemberExpression callee: obj.prop(args)Testing.newExpr — NewExpression: new callee(args)callee is a string it is automatically wrapped in id(), so newExpr('Date') and newExpr(id('Date')) are equivalent.Literals
Literals
Testing.strLiteral — StringLiteral: { type: "Literal", value }Testing.numLiteral — NumericLiteral: { type: "Literal", value }Testing.boolLiteral — BooleanLiteral: { type: "Literal", value }Object expressions
Object expressions
Testing.objectExpr — ObjectExpression with identifier-keyed propertiesid(). Omitted value defaults to strLiteral("").Testing.objectExprLiteralKeys — ObjectExpression with string literal keysstrLiteral() instead of id().Testing.objectExprWithSpread — ObjectExpression with a single SpreadElementStatements
Statements
Testing.throwStmt — ThrowStatementTesting.tryStmt — TryStatementTesting.returnStmt — ReturnStatementargument defaults to null.Testing.blockStmt — BlockStatementTesting.exprStmt — ExpressionStatementTesting.ifStmt — IfStatementifStmt() produces { type: "IfStatement" } with all fields set to null, suitable for enter/exit tracking.Testing.switchStmt — SwitchStatementTesting.forStmt — ForStatementTesting.forInStmt — ForInStatementTesting.forOfStmt — ForOfStatementTesting.whileStmt — WhileStatementTesting.doWhileStmt — DoWhileStatementExpressions
Expressions
Testing.arrowFn — ArrowFunctionExpressionbody defaults to blockStmt().Testing.binaryExpr — BinaryExpressionTesting.yieldExpr — YieldExpressionargument defaults to null.Testing.unaryExpr — UnaryExpressionprefix: true.Declarations and imports
Declarations and imports
Testing.varDecl — VariableDeclaration: const/let/var name = initTesting.varDeclarator — VariableDeclarator (standalone, without wrapping declaration)Testing.exportNamedDecl — ExportNamedDeclarationTesting.importDecl — ImportDeclaration with no specifiers: import ... from "source"Testing.importDeclWithSpecifiers — ImportDeclaration with specifiersTesting.importSpecifier — ImportSpecifier: { imported as local }local defaults to imported when omitted.Testing.importNamespaceSpecifier — ImportNamespaceSpecifier: * as localClass nodes
Class nodes
Testing.classDecl — ClassDeclarationTesting.propertyDef — PropertyDefinition (class field)Testing.methodDef — MethodDefinition (class method)TypeScript nodes
TypeScript nodes
Testing.tsAsExpr — TSAsExpression: expr as Typeid('_'). The type annotation is { type: typeKind }.Testing.tsUnionType — TSUnionType: A | B | CTesting.tsTypeRef — TSTypeReference: TypeNameTesting.tsTypeLiteral — TSTypeLiteral: { ... } with N TSPropertySignature membersTesting.interfaceDecl — TSInterfaceDeclaration: interface Name { }Testing.typeAliasDecl — TSTypeAliasDeclaration: type Name = ...Generic node builders
Generic node builders
Testing.astNode — Generic AST node with type and optional parent pointerTesting.withParentChain — Build a parent chain from outermost to innermost.parent links set on each ancestor.Testing.program — Program nodesourceType: "module".Tokens, comments, scope, and variables
Tokens, comments, scope, and variables
Testing.token — Mock Tokenstart: 0, end: value.length, and matching range and loc.Testing.comment — Mock Commentstart: 0, end: value.length + 4 (accounts for delimiters), and matching range and loc.Testing.scope — Mock Scopetype: "function", isStrict: false, upper: null, no variables.Testing.variable — Mock VariableTypes
ReportedDiagnostic
A single collected diagnostic from the mock context’s report function.
The
Testing module is only available from the effect-oxlint/testing subpath export. It is not included in the main effect-oxlint barrel to avoid pulling test infrastructure into production bundles.