Shared rules for ESLint 10 and Oxlint.
The repository contains the ESM plugin, canonical Oxlint configuration, rule specifications, package architecture, and release tooling.
mise install
pnpm install
pnpm test- Architecture defines public exports, configuration composition, build output, and verification boundaries.
- Rule policy explains universal rule rationale and expected replacements.
- Consistent blank lines defines the detailed classification and fixer contract.
- Upgrade Oxlint covers the dependency and policy upgrade procedure.
Every exported rule must express universal project policy. The recommended config enables the complete registry at error severity, and the test suite rejects registry entries that are absent from that config. A rule that cannot justify universal error severity must be redesigned or removed rather than moved to an optional preset. Rule options adapt repository ownership or boundary conventions without disabling the rule.
pnpm add -D @utilfirst/eslint-plugin// eslint.config.mjs
import utilfirst from "@utilfirst/eslint-plugin";
export default [
utilfirst.configs.recommended,
// ...your other configs
];Rules with repository-specific ownership or boundary conventions accept options in either runtime. Apply option overrides after the recommended config so the rule stays enabled.
export default [
utilfirst.configs.recommended,
{
rules: {
"utilfirst/no-module-mocking": [
"error",
{ internalModulePrefixes: ["@workspace/"] },
],
"utilfirst/require-repository-test-subject": [
"error",
{ internalModulePrefixes: ["@workspace/"] },
],
"utilfirst/no-positional-boolean-parameters": [
"error",
{ allowFunctionNames: ["protocolCallback"] },
],
"utilfirst/no-unknown-parameters": [
"error",
{ allowParameterNames: ["externalPayload"] },
],
"utilfirst/prefer-options-parameter": [
"error",
{ allowFunctionNames: ["protocolCallback"] },
],
},
},
];internalModulePrefixesmarks package-style import prefixes as repository-owned forno-module-mockingandrequire-repository-test-subject.allowFunctionNamespreserves named functions whose positional boolean or multi-input signature is fixed by an external protocol.allowParameterNamespreservesunknownparameters whose names identify an externally fixed callback or interface signature.
For Oxlint TypeScript configuration, import the canonical shared policy and layer repository and platform boundaries after it:
// oxlint.config.ts
import { defineConfig } from "oxlint";
import { oxlintBaseConfig } from "@utilfirst/eslint-plugin/oxlint";
export default defineConfig({
extends: [oxlintBaseConfig],
ignorePatterns: ["dist/**", "node_modules/**"],
plugins: ["nextjs", "node"],
});The base config owns the shared environment, rule set, and the pattern-level overrides for config modules, plain JavaScript, and CommonJS files. A repository config adds only its ignore patterns, framework plugins, and repository-specific rules. Keep file-specific exceptions inline at the owning line with a reason instead of adding file-targeted overrides.
The base config owns shared categories, environment defaults, unused-disable reporting, TypeScript type checking, browser React, accessibility, JSDoc, module-boundary, and test-precision policy, compiler-diagnostic overrides, React settings, native rules, and every exported custom rule. Repositories retain ignore paths, platform plugins, platform environments, generated-file treatment, and reasoned exceptions. Non-browser React consumers must disable or replace browser accessibility policy at their platform boundary.
docs/reference/rule-policy.md explains the policy boundary and expected replacement for every rule. The implementations and colocated tests remain the executable behavior owners.
| Rule | Description |
|---|---|
consistent-blank-lines |
Apply tight, separate, or preserved gaps between statements and JSX children |
no-call-count-only-test |
Reject tests supported only by mock call counts or omission |
no-chained-type-assertions |
Reject chained TypeScript assertions |
no-enum-declarations |
Reject repository-owned enums other than ambient declarations |
no-imported-constant-restatement |
Require behavior evidence instead of imported constant restatements |
no-known-value-widening |
Reject known values widened into broad target types |
no-module-mocking |
Reject Vitest and Jest mocking of repository-owned modules |
no-negated-throw-assertion |
Replace negated throw assertions with direct execution |
no-object-parameters |
Reject object function parameters |
no-positional-boolean-parameters |
Reject positional boolean flags on directly named callable contracts |
no-promise-settlement-only-assertion |
Require a promise assertion to describe its result or specific failure |
no-reflect-apply |
Reject Reflect.apply |
no-reflect-get |
Reject Reflect.get |
no-test-snapshots |
Require explicit observable assertions instead of snapshots |
no-truthy-falsy-assertion |
Require exact expected values instead of truthiness |
no-uncontrolled-time-in-test |
Require clock control in each owning test or setup scope |
no-unknown-parameters |
Keep unknown inputs at declared or input-consuming decoder boundaries |
no-unknown-returns |
Reject unknown return contracts |
no-unknown-type-aliases |
Reject type aliases that resolve to unknown |
no-unsafe-dictionary-type |
Reject object and Map dictionary contracts with broad value types |
no-unhandled-detached-promises |
Require terminal rejection handling on void-marked detached chains |
no-widen-then-assert |
Reject const flows that widen a known value before narrowing it |
prefer-forwarded-props-order |
Put forwarded props before component-controlled JSX attributes |
prefer-hook-order |
Order built-in hooks by context, state, derivation, and effect role |
prefer-jsx-boolean-and |
Require boolean JSX guards and normalize null-branch conditionals |
prefer-named-react-type-imports |
Require named react type imports instead of the ambient React namespace |
prefer-options-parameter |
Require options objects for named callable contracts with three or more inputs |
prefer-switch-discriminator-chain |
Require a switch for four or more equality branches on one discriminator |
prefer-top-level-function-declarations |
Require declarations for direct top-level function bindings and default exports |
require-lint-suppression-reason |
Require a forcing reason on lint disable directives |
require-repository-test-subject |
Require behavioral tests to import repository-owned code |
require-safety-comment-for-type-assertion |
Require one SAFETY: comment for each outermost non-const assertion |
require-special-comment-tag |
Require canonical uppercase tags and colons on special comments |
The rules other than consistent-blank-lines, no-call-count-only-test, no-enum-declarations, no-imported-constant-restatement, no-negated-throw-assertion, no-positional-boolean-parameters, no-promise-settlement-only-assertion, no-test-snapshots, no-truthy-falsy-assertion, no-uncontrolled-time-in-test, no-unhandled-detached-promises, prefer-forwarded-props-order, prefer-hook-order, prefer-jsx-boolean-and, prefer-options-parameter, require-lint-suppression-reason, require-repository-test-subject, and require-special-comment-tag, along with their helpers, are adapted from dmmulroy/anti-slop under the MIT License. The package's LICENSE retains the copyright and permission notice.
pnpm install
pnpm test # unit, dual-runtime, and packed-artifact tests
pnpm run build # tsdown → dist/
pnpm run lint # oxlint + prettier + publintMIT. The package includes third-party code under the same license.