This guide walks you through writing a custom oxlint rule with effect-oxlint from scratch. You will define a rule usingDocumentation 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.
Rule.define, explore the convenience factories for common patterns, assemble your rules into a plugin, and verify them with the built-in testing utilities.
Define a rule with Rule.define
Rule.define is the primary entry point. Write create as an Effect generator: use yield* to access RuleContext, create Ref-based state, and return a visitor map where each handler returns an Effect<void>.The example below bans JSON.parse and JSON.stringify, directing developers to use Schema for JSON decoding instead:no-json-parse.ts
AST.matchMember returns Option<ESTree.MemberExpression>. When it returns Some, the matched node is narrowed and passed directly to ctx.report. When it returns None, the handler returns Effect.void — no diagnostic, no side effects.Use convenience factories for common patterns
For the most common ban patterns, effect-oxlint provides factory functions that generate a full
CreateRule from a single call. These cover member expressions, imports, statements, bare identifier calls, new expressions, method calls, and combinations of multiple patterns.rules.ts
Assemble rules into a plugin
Use
Plugin.define to assemble your rules into an oxlint-compatible plugin. The object maps rule names (as they will appear in oxlint config) to CreateRule instances.plugin.ts
Write tests with Testing
effect-oxlint ships a
Testing module as a dedicated subpath export. It provides mock AST node builders, a synchronous rule runner, and assertion helpers for @effect/vitest.no-json-parse.test.ts
Testing.runRule takes a rule, a visitor key, and a mock AST node. The available node builders include id, memberExpr, computedMemberExpr, chainedMemberExpr, callExpr, callOfMember, importDecl, newExpr, throwStmt, tryStmt, ifStmt, program, objectExpr, and more.Next steps
Visitor combinators
Compose, merge, filter, and accumulate visitors for complex traversal logic.
AST matching
Use Option-returning matchers with the dual API for safe, composable queries.
Diagnostics and autofixes
Build structured diagnostics with composable autofix functions.
Installation
Runtime support details for Bun, Deno, and Node.js.