@2digits/oxlint-plugin
v0.0.6
Published
Custom Oxlint rules for 2digits projects.
Readme
@2digits/oxlint-plugin
Custom Oxlint JavaScript plugin rules used by
@2digits/oxlint-config.
The recommended set is enabled by default by @2digits/oxlint-config. The opt-in prefer-effect-filesystem and
prefer-effect-path rules are excluded because the configured @effect/tsgo/nodeBuiltinImport diagnostic already
enforces those imports more broadly. To register the plugin directly:
import { defineConfig } from 'oxlint';
import { recommendedRules } from '@2digits/oxlint-plugin';
export default defineConfig({
jsPlugins: [{ name: '2digits', specifier: import.meta.resolve('@2digits/oxlint-plugin') }],
rules: recommendedRules,
});Rules
The package exports all rules as rules, their names as RuleName, and the default error-level configuration as
recommendedRules.
- Copied and adapted Effect practices:
avoid-data-tagged-error,ban-error-string,effect-promise-vs-trypromise,no-logging-in-catch, andthrow-in-effect-gen. - Syntax-safe Effect diagnostics proposed in open
Effect-TS/tsgoissues: the remainingcors-*,dual-*,no-*,prefer-*,preserve-*, andrequire-*Effect rules. - Effect v4 API guidance for Array, DateTime, Duration, Encoding, FileSystem, Filter, Headers, Match, Path, and Url,
plus interruptible
Effect.tryPromisethunks. - Effect and Alchemy import policy: namespace imports from PascalCase submodule entrypoints, canonical Effect aliases,
and no root-barrel module imports.
@effect/vitestand lowercase unstable barrels are intentionally exempt. - Alchemy v2 practices: every
alchemy-*rule.
See each rule's meta.docs.url for its upstream rule, issue, or framework documentation. Copied-code attribution is in
NOTICE.
Automatic fixes
Run vp lint --fix to apply fixes from prefer-effect-duration, no-empty-effect-callback,
no-effect-alchemy-barrel-imports, prefer-effect-alchemy-namespace-imports,
alchemy-no-v1-worker-properties, and alchemy-no-deprecated-docker-constraints.
Fixes skip ambiguous bindings, conflicting properties, and unsupported import references.
Adding a rule
Oxlint's JavaScript plugin API is currently alpha and does not expose type information. Keep rules syntax-safe and leave
semantic Effect checks to @effect/tsgo / @effect/language-service.
Oxfmt formats imports but does not enforce package-specific import architecture. The Effect language service's
namespaceImportPackages and importAliases settings guide generated auto-imports only, so the plugin enforces the same
policy for handwritten imports.
- Add one rule file under
src/rules/alchemyorsrc/rules/effectwithdefineRulethroughdefineSyntaxRuleordefineEffectRule. - Register it in
src/rules/index.ts.src/index.tsautomatically includes it inrecommendedRules. - Add a matching test file under
test/ruleswith valid and invalidRuleTestercases. - Run
vp test,vp check, andvp run build.
defineEffectRule resolves namespace and named imports from effect, @effect/*, and alchemy/* entrypoints, so rules
should match canonical API paths instead of hard-coding local import names.
