Effect-first library for writing oxlint custom lint rules.
Core rule builder and convenience factories.
define— writecreateas an Effect generator withRefstate,Schema-decoded options, and typed visitorsmeta— buildRuleMetawith sensible defaultsbanMember— banobj.propmember expression accessbanImport— ban imports matching a source string or predicatebanCallOf— ban bare identifier call expressionsbanNewExpr— bannewexpressions with given callee namesbanStatement— ban a specific statement typebanMultiple— combine call, new-expr, member, import, and statement bans into one rule
Composable visitor construction.
on/onExit— single-entry visitor for enter/exit phasesmerge— combine multiple visitors (same-key handlers run sequentially)tracked— enter/exitRef<number>counter replacing mutablelet depth = 0filter— conditionally apply a visitor based on filename predicate (dual API)accumulate— collect items during traversal, analyze atProgram:exit
Option-returning pattern matchers with dual API (data-first and data-last).
matchMember/isMember— matchobj.propmember expressionsmatchCallOf/isCallOf— matchobj.prop(...)call expressionsmatchImport/isImport— match import declarations by sourcecalleeName/memberNames/importSource— identifier extractionobjectKeys/objectHasKey/objectGetValue— object expression helpersnarrow— safe node type narrowing toOptionmemberPath— extract full member chaina.b.c→['a', 'b', 'c']findAncestor/hasAncestor— parent chain walking (dual API)
Structured diagnostic construction and composable autofixes.
make/fromId— diagnostic constructorswithFix/withSuggestions— attach fixes/suggestions (dual API)replaceText/insertBefore/insertAfter/removeFix— fix operationscomposeFixes— compose multiple fix functions into one
Effect service wrapping the oxlint rule context.
RuleContext—ServiceMap.Servicewithreport,id,filename,cwd,options,sourceCode,languageOptions,settings- Convenience accessors:
id,filename,cwd,sourceCode,text,ast,report
Effectful queries over tokens, comments, scope, and source text.
- 25 wrapped methods returning
Effect<T, never, RuleContext>withOptionfor nullable results
Variable lookup and reference analysis with Option.
findVariable/findVariableUp— scope-chain lookup (dual API)isUsed/isWritten/isReadOnly— variable predicatesgetReferences/getReadReferences/getWriteReferences— reference filteringupper/childScopes/variables/throughReferences/isStrict— scope navigation
Plugin definition and composition.
define— create a typed oxlint plugin from a name and rule mapmerge— merge multiple plugins into one
Comment type predicates.
isLine/isBlock/isShebang/textisJSDoc/isDisableDirective/isEnableDirective
Token type predicates with dual API for isKeyword and isPunctuator.
isKeyword/isPunctuator— dual API (data-first and data-last)isIdentifier/isString/isNumeric/isBoolean/isNull/isTemplate/isRegularExpression/isPrivateIdentifiervalue/type— accessors
Mock builders, rule runners, and assertion helpers.
- 50+ AST node builders (
id,memberExpr,callExpr,importDecl,throwStmt,classDecl, etc.) createMockContext/mockRuleContextLayer/withMockRuleContext— mock context factoriesrunRule/runRuleMulti— run rules against visitor events and collect diagnosticsmessages/messageIds— diagnostic accessors returningOptionexpectDiagnostics/expectNoDiagnostics— assertion helpers
All @oxlint/plugins types re-exported with Oxlint prefix where needed (ESTree, OxlintPlugin, OxlintComment, OxlintToken, etc.) so consumers don't need a direct dependency for type imports.