Effect-first library for writing oxlint custom lint rules. Wraps @oxlint/plugins in Effect v4 idioms.
bun run check # lint + format + typecheck (with auto-fix)
bun run test # vitest run (all tests)
bun run typecheck # tsgo type-check onlybunx vitest run test/Rule.test.ts # single file
bunx vitest run -t "reports for matching" # by test name pattern
bunx vitest run test/AST.test.ts -t "matchMember" # file + nameAll three must pass:
bun run check && bun run test && bun run typechecksrc/ 12 modules — AST, Comment, Diagnostic, Plugin, Rule, RuleContext,
Scope, SourceCode, Testing, Token, Visitor, index (barrel)
test/ 11 test files — one per source module
vite.config.ts Lint rules, formatting, test config (vite-plus)
Single-package project. Bun is the package manager (bun@1.3.11). No monorepo tooling.
- Tabs for indentation (width 4), print width 80
- Single quotes, semicolons, no trailing commas
- Arrow parens always:
(x) => ... - LF line endings
- JSON files: 2-space indentation
- Type-only imports first:
import type { ... } from '...' - External namespace imports:
import * as Arr from 'effect/Array' - Internal imports last:
import * as AST from './AST.ts'
Canonical Effect aliases (required):
import * as Arr from 'effect/Array';
import * as Option from 'effect/Option';
import * as P from 'effect/Predicate';
import * as R from 'effect/Record';
import * as Schema from 'effect/Schema';
import * as Str from 'effect/String';Core combinators from root: import { Effect, pipe, flow, Match } from 'effect'
— or from dedicated module: import * as Effect from 'effect/Effect'
All local imports include .ts extension: './AST.ts', not './AST'.
- Source files: PascalCase (
Rule.ts,SourceCode.ts,RuleContext.ts) - Test files:
<ModuleName>.test.tsmatching source name - Functions/variables: camelCase (
matchMember,fromOxlintContext) - Types/interfaces/classes: PascalCase (
RuleConfig,EffectVisitor) - Service keys: namespaced strings (
'effect-oxlint/RuleContext')
Every source file follows this layout:
- Module-level JSDoc with
@sincetag - Imports (ordered as above)
- Sections separated by
// ---...--- // Section Name // ---...--- - Exported functions with JSDoc (
@since,@example) - Internal helpers marked
/** @internal */
readonlyon all interface fields and function parametersReadonlyArray<T>instead ofT[]- No
any, no@ts-ignore, no non-null assertions (!) exactOptionalPropertyTypesandnoUncheckedIndexedAccessare enabled- Use
| undefinedexplicitly for optional properties
- Option for absence: Convert nullable values with
Option.fromNullishOrat boundaries. Chain withOption.map,Option.flatMap,Option.match. Never useOption.getOrThrow. - Dual API: Public combinators support data-first and data-last via
dual:export const matchMember: { (obj: string, props: string[]): (node: ESTree.Node) => Option<...>; (node: ESTree.Node, obj: string, props: string[]): Option<...>; } = dual(3, (node, obj, props) => { ... });
- Effect.gen with function*: For effectful setup and complex combinators
- Effect.runSync only at runtime boundaries: The FFI bridge in
Rule.tsand test harnesses - Ref for mutable state:
Ref.make/Ref.updatein effectful contexts - Effect.void for no-ops: Not
Effect.succeed(undefined) - pipe for composition: Especially Option chains and Effect pipelines
- Context.Service for services: With unique namespaced string key
Arr.*overArray.prototype.*—Arr.map,Arr.filter,Arr.reduce,Arr.contains,Arr.match,Arr.joinR.*overObject.*—R.union,R.filter,R.mapStr.*overString.prototype.*—Str.trim,Str.startsWith,Str.splitP.isString,P.isObjectover rawtypeofchecksOptionovernull | undefinedin domain code- No imperative
for/for...ofloops in domain code
- Return
Option.none()orEffect.voidfor no-op / absent paths - No
throwortry/catchin domain code (useEffect.try,Effect.tryPromise) - Tagged errors via
Schema.TaggedErrorClassfor cross-module failures - Test files may use
throwandtry/catch(lint overrides configured)
- Framework: Vitest 4 +
@effect/vitest - Import test utilities:
import { describe, expect, test } from '@effect/vitest' - Effectful tests:
it.effect('name', () => Effect.gen(function* () { ... }).pipe(Effect.provide(TestLayer))) - Pure tests:
test('name', () => { expect(...).toBe(...) }) - Use
testfor pure tests,it.effectfor effectful tests (neveritfor pure tests) - Test module
src/Testing.tsprovidescreateMockContext,runRule,expectDiagnostics - Section separators between test groups (same
// ---format as source)
- Every exported API has JSDoc with
@since 0.x.0 - Module-level doc block at top of each file with description and
@since @internalmarks non-public exports@examplewith code blocks for key APIs@deprecatedwhere upstream deprecation exists
- Re-export oxlint types with
Oxlintprefix to avoid collision:OxlintPlugin,OxlintComment RuleContextis aContext.Servicewrapping oxlint's contextwithSourceCodepattern:Effect.service(RuleContext).pipe(Effect.map(ctx => fn(ctx.sourceCode)))- Visitors are
Record<string, (node: ESTree.Node) => Effect<void>> toOxlintVisitorconverts Effect visitors to plain oxlint visitors at the boundary- FFI boundary casts (
as never) are used inTesting.tsnode builders and are documented
The project dogfoods its own oxlint-effect rules. Key enforced rules:
effect/throw-in-effect-gen: error — no throwing inside Effect.geneffect/vm-in-wrong-file: error — view models in correct fileseffect/no-opaque-instance-fields: error — no opaque instance fields@typescript-eslint/no-explicit-any: error@typescript-eslint/no-non-null-assertion: error- ~50 additional
effect/*rules atwarnlevel (prefer-option-over-null, avoid-native-fetch, prefer-match-over-switch, etc.)
Test file overrides: avoid-untagged-errors and avoid-try-catch disabled.
FFI boundary overrides: prefer-option-over-null, casting-awareness, avoid-any, avoid-native-object-helpers, effect-run-in-body disabled for SourceCode.ts, Testing.ts, Rule.ts, Visitor.ts.