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.
Visitor module provides combinators for building and composing effectful AST visitors. A visitor is a map from AST node type names to EffectHandler functions that return Effect<void, never, RuleContext>. Combinators like merge, tracked, filter, and accumulate let you build complex traversal logic from small, focused pieces without mutable state.
Types
EffectHandler
An effectful visitor handler. Receives an AST node and returns anEffect<void> that may read or write Ref state and report diagnostics via RuleContext.
never. Handlers cannot fail via Effect.fail because oxlint’s plugin API is synchronous. If a handler calls a fallible effect, catch the error inside the handler and surface it as a diagnostic.
EffectVisitor
A map from AST node type names (and"NodeType:exit" variants) to effectful handlers. This is the internal representation used by all combinators.
TypedEffectVisitor
A typed variant ofEffectVisitor where known oxlint visitor keys provide a correctly narrowed node type to each handler. Return this from Rule.define’s create generator to get typed nodes without manual narrowing.
VisitorNodeType
Resolves a visitor key string to its narrowed ESTree node type. For known keys (e.g.'CallExpression') returns the specific ESTree type; for unknown keys falls back to ESTree.Node.
Visitor.on
Creates a single-entry visitor that handles one node type on enter.The ESTree node type name to handle (e.g.
'CallExpression', 'ThrowStatement'). Known keys provide a narrowed node type to the handler.The effectful handler. Receives the narrowed node type for known keys.
Visitor.onExit
Creates a single-entry visitor that handles one node type on exit (after all descendants have been visited).The ESTree node type name. The handler is registered under
"NodeType:exit".The effectful handler called when the traversal exits the node.
Visitor.merge
Merges multiple visitors into one. When two visitors handle the same node type, both handlers run sequentially from left to right.Any number of
EffectVisitor maps to merge. Same-key handlers are sequenced left to right.Visitor.tracked
Creates an enter/exit visitor pair that increments aRef<number> on enter and decrements on exit, but only when the predicate matches. This replaces the common let depth = 0 mutable counter pattern.
The node type to track depth for.
Called with the narrowed node type. Only when this returns
true is the Ref updated.The depth counter ref. Incremented on enter, decremented on exit.
Visitor.filter
Conditionally applies a visitor based on a predicate evaluated once at create time. Useful for restricting a visitor to specific files (e.g. skip test files).Receives the current file’s path. Return
true to apply the visitor, false to return an empty visitor.The visitor to apply when the predicate returns
true.filter returns an Effect<EffectVisitor> because it reads RuleContext to access the filename. Use yield* inside your create generator to unwrap it.Visitor.accumulate
Accumulates values during traversal and analyzes them atProgram:exit. The extract function is called for each node of nodeType; if it returns Option.some(value), that value is collected. At Program:exit, the analyze function receives all collected items.
The AST node type to extract values from during traversal.
Called for each matching node. Return
Option.some(value) to accumulate a value, or Option.none() to skip.Called once at
Program:exit with all accumulated values. Report diagnostics here.accumulate returns an Effect<EffectVisitor> because it creates a Ref internally. Use yield* inside your create generator to unwrap it.