Adeel Imran
Engineering field note12 min read

Stop begging AI agents in markdown files. Enforce the rules in 8 seconds.

Moving 288 strict rules and custom repo checks from ESLint and Prettier to oxlint and oxfmt turned our linter into a fast guardrail for AI-written pull requests.

Adeel Imran

Written by

Adeel Imran

Teams keep stuffing longer instructions into AGENTS.md and CLAUDE.md, then act surprised when an agent ignores line 47. It ships a raw <input>. It hard-codes bg-zinc-900. It pastes a bare // eslint-disable-next-line and moves on.

A prompt is a suggestion. A failing check is a wall.

The catch is that strict ESLint gets so slow, as a repo grows, that teams stop adding the exact custom rules that prevent this drift. I hit that wall on a self-hosted social media publishing tool I maintain for internal use. I use the same pattern to keep client React and Next.js codebases clean. Next.js 16, TypeScript 5.9, 524 linted files, 288 active rules. After the switch to oxfmt and oxlint, CI lint dropped from a 69-second median to 18.4 to 26.2 seconds. Local lint dropped from 37.6 seconds to 8.8 seconds. The suite that proves our custom rules still fire went from 11 cases to 21, and still finished in 7 to 8 seconds. The install also shed 146 packages.

That speed is what let us keep the wall strict.

The first check is the one that matters

Every number below comes from five runs of the PR quality workflow on ubuntu-latest with 2 threads, before and after the switch.

CheckBefore (ESLint and Prettier)After (oxlint and oxfmt)Change
npm run lint in CI (524 files, 288 rules)69s median (60s to 83s)18.4s to 26.2s3.1x to 3.6x faster
npm run lint local37.6s8.8s4.3x faster
npm run lint:rules in CI17s (11 test cases)7s to 8s (21 test cases)2x to 2.5x faster, 11 cases to 21 cases
Combined lint and lint:rules in CI86s median26s to 35s3.3x faster, about 60s saved
Format check in CI (changed PR files)Prettier13ms to 19msSub-second
Full-repo format check (701 files)5.3s local213ms CI, 1.6s local3.3x faster local
Total installed packages (npm ci)1,668 packages1,522 packages146 fewer packages

Total job time dropped from a 5m 31s median to 4m 22s. That is 21% faster, or 69 seconds shorter. Jest still takes about 63 seconds. next build still takes about 90 seconds. Those two steps still dominate the job. I would not sell this as a CI miracle. The win is the first check, the one agents and developers run on every edit.

An agent works in a tight loop. It edits a file, runs the checks, reads the failures, and tries again. Thirty extra seconds in that loop add up across dozens of iterations on one feature. A 69-second lint step also makes you hesitate to turn on type-aware TypeScript rules, or to add the repo-specific checks that actually catch agent mistakes. Those would have made a slow step even slower.

After the switch, those rules stayed on. We still fail the build on any warning. Tailwind and Next.js checks still run. The tests that prove the rules fire went from 11 cases to 21. The lint step got faster anyway.

Ship the formatter in its own pull request

A formatter rewrite touches whitespace across the repository. Mix that with new lint behavior in the same diff and a reviewer cannot tell formatting from a real change. I put oxfmt in its own pull request first.

I installed oxfmt 0.80.0 and generated .oxfmtrc.json from the existing Prettier config.

npm install -D oxfmt
npx oxfmt --migrate=prettier

npx oxfmt --migrate=prettier copies your Prettier options into .oxfmtrc.json. Then set "sortPackageJson": false. oxfmt can reorder keys in package.json, and that reordering creates a large, unhelpful diff. If ESLint is still in the repo, keep eslint-config-prettier installed until you replace it, so the two tools do not fight.

Here is the .oxfmtrc.json I shipped:

{
	"$schema": "./node_modules/oxfmt/configuration_schema.json",
	"semi": true,
	"trailingComma": "all",
	"singleQuote": true,
	"printWidth": 80,
	"tabWidth": 2,
	"useTabs": false,
	"arrowParens": "always",
	"endOfLine": "lf",
	"proseWrap": "preserve",
	"bracketSpacing": true,
	"bracketSameLine": false,
	"jsxSingleQuote": false,
	"sortPackageJson": false,
	"ignorePatterns": [
		"node_modules",
		".next",
		"dist",
		"out",
		"build",
		".cache",
		".turbo",
		"package-lock.json"
	],
	"sortImports": {
		"customGroups": [
			{ "groupName": "react", "elementNamePattern": ["react"] },
			{ "groupName": "next", "elementNamePattern": ["next/**"] }
		],
		"groups": [
			"builtin",
			"react",
			"next",
			"external",
			"internal",
			"parent",
			"sibling",
			"index",
			["type-builtin", "type-external"]
		],
		"newlinesBetween": true,
		"ignoreCase": true
	},
	"overrides": [
		{
			"files": ["**/*.md"],
			"options": { "sortImports": false }
		}
	]
}

I updated the scripts in package.json, the lint-staged hooks, and the VS Code extension recommendation to oxc.oxc-vscode.

In GitHub Actions, the format check runs only on the files changed in the pull request. The command uses git diff -z and xargs -0. Next.js route groups such as app/(public) contain parentheses, and those break ordinary shell splitting.

- name: Check formatting (PR changed files)
  if: github.event_name == 'pull_request'
  run: |
    git diff -z --name-only --diff-filter=ACMRT "origin/${{ github.base_ref }}...HEAD" -- '*.js' '*.jsx' '*.ts' '*.tsx' '*.json' '*.md' '*.css' > "$RUNNER_TEMP/changed-files.txt"
    xargs -0 -r -a "$RUNNER_TEMP/changed-files.txt" npx oxfmt --check --no-error-on-unmatched-pattern --

Keep every rule an error

I installed oxlint 1.95.0 and oxlint-tsgolint 7.0.2009. oxlint-tsgolint supplies the type-aware TypeScript rules, including typescript/no-floating-promises, typescript/no-unsafe-assignment, and typescript/switch-exhaustiveness-check.

npm install -D oxlint oxlint-tsgolint

Then I removed ESLint and the plugins oxlint already covers. That was 13 ESLint packages in this repo. node_modules shrank by 146 packages.

The top of .oxlintrc.json sets three options that keep the same strictness:

{
	"$schema": "./node_modules/oxlint/configuration_schema.json",
	"plugins": ["typescript", "unicorn"],
	"categories": {
		"correctness": "off"
	},
	"options": {
		"typeAware": true,
		"reportUnusedDisableDirectives": "error",
		"denyWarnings": true
	},
	"settings": {
		"better-tailwindcss": {
			"entryPoint": "app/globals.css"
		}
	},
	"jsPlugins": [
		"./lint/local-plugin.mjs",
		{
			"name": "next-js",
			"specifier": "@next/eslint-plugin-next"
		}
	]
}

Each option does one job:

  • typeAware: true turns on TypeScript type-checked rules through oxlint-tsgolint.
  • denyWarnings: true fails the run if any warning appears.
  • reportUnusedDisableDirectives: "error" fails the run as soon as a disable comment is no longer needed.

Don't leave rules as warnings. Set every rule you care about to error. Warnings become background noise. Humans skip them, and agents do too. A tight check is easier to live with than a backlog of "we'll fix that later."

The repo had used eslint-suppressions.json to freeze 14 legacy violations. I deleted that file and moved each exception into an inline disable comment with a written reason. The rules themselves were not relaxed.

Keep the Next.js, Tailwind, and SonarJS rules you already depend on

oxlint does not have a native version of every rule a Next.js app may rely on. It can load standard ESLint plugins through jsPlugins.

These three stayed active that way:

  • @next/eslint-plugin-next for Next.js rules not yet covered by the built-in nextjs plugin.
  • eslint-plugin-sonarjs for sonarjs/cognitive-complexity with a max of 15, sonarjs/no-identical-functions, and sonarjs/no-collapsible-if.
  • eslint-plugin-better-tailwindcss to block unknown classes, conflicting classes, and hard-coded palette colors like bg-zinc-900 outside components/ui/**.

Native oxlint plugins handle most of the 288 rules: typescript, react, nextjs, import, jsx-a11y, jest, and unicorn. jsPlugins covers the rest.

Turn repeated review comments into rules

Generic lint rules catch syntax bugs. They will not stop an agent from ignoring the team's component library, or from writing copy the product does not use.

I keep those checks in a small JS plugin at lint/local-plugin.mjs, loaded from .oxlintrc.json under jsPlugins. Each of these eight rules exists because the same mistake kept showing up in review:

  1. no-raw-input bans a raw <input> in JSX, except type="hidden". Agents reach for the native tag and skip Input from @/components/ui/input, so the field loses the shared styles and behavior.
  2. no-dash-characters bans em dashes and en dashes in UI strings and JSX copy. Models love those characters in product text. We don't use them in the UI.
  3. require-directive-description requires a reason after -- on every disable comment. Without that, disables pile up and nobody knows if they still belong.
  4. no-unlimited-disable rejects a disable comment that does not name the rules it turns off. A bare disable silences every rule in that range, which is a common way to get CI green.
  5. disable-enable-pair requires a matching enable comment for every block disable. Miss the enable, and the rest of the file goes unchecked.
  6. no-extraneous-dependencies rejects imports that are missing from package.json, and devDependencies imported from production files. Agents invent packages that were never installed, or they pull test-only libraries into app code.
  7. no-useless-path-segments flags messy relative imports like ../app/../lib/env or ./nested/index. Autocomplete and agents both produce these, and they get worse when you move a file.
  8. camelcase requires camelCase on declared identifiers, and allows SCREAMING_SNAKE_CASE constants. Copied or generated snippets mix casing, which makes names harder to search for.

Write the rule, wire it, and prove it fires

An oxlint JS plugin exports a name and a map of rules. Each rule has meta and a create(context) function that returns visitors. I put the file at lint/local-plugin.mjs.

Here is no-raw-input, a real rule from the plugin. It visits JSXOpeningElement nodes, allows type="hidden", and reports everything else:

function isHiddenInput(openingElement) {
	return openingElement.attributes.some(
		(attribute) =>
			attribute.type === 'JSXAttribute' &&
			attribute.name.name === 'type' &&
			attribute.value?.type === 'Literal' &&
			attribute.value.value === 'hidden',
	);
}

const noRawInput = {
	meta: {
		type: 'suggestion',
		docs: { description: 'Use the shared input components, not raw <input>.' },
		schema: [],
	},
	create(context) {
		return {
			JSXOpeningElement(node) {
				if (node.name.type !== 'JSXIdentifier' || node.name.name !== 'input') {
					return;
				}
				if (isHiddenInput(node)) return;
				context.report({
					node,
					message:
						'Use Input from @/components/ui/input (or Checkbox, RadioGroup, Switch from components/ui). Raw <input> is only for type="hidden".',
				});
			},
		};
	},
};

export default {
	meta: { name: 'local' },
	rules: {
		'no-raw-input': noRawInput,
	},
};

Load the plugin and turn the rule on in .oxlintrc.json. oxlint looks the rule up as local/no-raw-input, because meta.name is local:

{
	"jsPlugins": ["./lint/local-plugin.mjs"],
	"rules": {
		"local/no-raw-input": "error"
	}
}

If the rule should not apply everywhere, put it in an override. In this app, no-raw-input is on for app, components, and lib files, and off inside components/ui/**, where the shared input primitives live.

Then prove the rule still fires. npm run lint:rules runs tsx scripts/check-lint-rules.ts. The script writes tiny fixture files under app/__lint_fixtures__, runs oxlint --format=json on them, and checks two things. The rule must report on bad code. It must stay quiet on code you meant to allow. oxlint reports the rule as local(no-raw-input) in that JSON.

A pair of fixtures for no-raw-input looks like this:

{
	rule: 'local(no-raw-input)',
	file: 'raw-input.tsx',
	source: 'export function Field() {\n  return <input type="text" />;\n}\n',
},
{
	rule: 'local(no-raw-input)',
	file: 'hidden-input.tsx',
	source:
		'export function Field() {\n  return <input type="hidden" name="id" value="1" />;\n}\n',
	expectClean: true,
},

Once a fixture is in that list, a silent rule breaks CI. The rest of the script is below.

Built-in rules sit next to the local plugin. no-restricted-properties blocks direct process.env reads outside lib/env.ts. max-lines is set to 1,000, and max-lines-per-function is set to 300. A file longer than 1,000 lines, or a function longer than 300 lines, fails the lint run. That stops an agent from dumping a huge generated file into a pull request.

If a rule goes silent, fail the build

If a rule silently stops firing, the build stays green and nobody notices the check is missing. A migration or a plugin upgrade can typo a rule name, or change a glob, and disable a check without a failing build.

scripts/check-lint-rules.ts writes temporary fixtures and runs oxlint --format=json. It asserts that every critical rule fires on bad code, and stays quiet on valid code. The repo now has 21 of these cases, up from 11 before the switch. The script runs in 7 to 8 seconds in CI.

Here is the core of scripts/check-lint-rules.ts:

import { spawnSync } from 'node:child_process';
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
import path from 'node:path';

type Case = {
	rule: string;
	file: string;
	source: string;
	expectClean?: boolean;
};

const FIXTURE_DIR = path.join(process.cwd(), 'app', '__lint_fixtures__');

const CASES: Case[] = [
	{
		rule: 'eslint(no-restricted-properties)',
		file: 'process-env.ts',
		source: 'export const key = process.env.STRIPE_API_KEY;\n',
	},
	{
		rule: 'local(no-raw-input)',
		file: 'raw-input.tsx',
		source: 'export function Field() {\n  return <input type="text" />;\n}\n',
	},
	{
		rule: 'local(no-raw-input)',
		file: 'hidden-input.tsx',
		source:
			'export function Field() {\n  return <input type="hidden" name="id" value="1" />;\n}\n',
		expectClean: true,
	},
	{
		rule: 'typescript(no-floating-promises)',
		file: 'floating.ts',
		source:
			'async function save(): Promise<void> {}\n\nexport function onSave(): void {\n  save();\n}\n',
	},
	{
		rule: 'local(require-directive-description)',
		file: 'disable.ts',
		source:
			'// eslint-disable-next-line no-console\nconsole.log("debug");\n\nexport {};\n',
	},
];

function lintFixtures(files: string[]) {
	const run = spawnSync(
		path.join(process.cwd(), 'node_modules', '.bin', 'oxlint'),
		['--format=json', ...files],
		{ encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
	);
	if (run.error) throw run.error;
	return (JSON.parse(run.stdout) as { diagnostics: { code?: string; filename: string }[] })
		.diagnostics;
}

mkdirSync(FIXTURE_DIR, { recursive: true });
const failures: string[] = [];

try {
	for (const testCase of CASES) {
		writeFileSync(path.join(FIXTURE_DIR, testCase.file), testCase.source);
	}
	const diagnostics = lintFixtures(CASES.map((c) => path.join(FIXTURE_DIR, c.file)));

	for (const testCase of CASES) {
		const fired = diagnostics.some(
			(d) => path.basename(d.filename) === testCase.file && d.code === testCase.rule,
		);
		if (testCase.expectClean && fired) {
			failures.push(`${testCase.file}: ${testCase.rule} fired on allowed code`);
		}
		if (!testCase.expectClean && !fired) {
			failures.push(`${testCase.file}: ${testCase.rule} did not fire`);
		}
	}
} finally {
	rmSync(FIXTURE_DIR, { recursive: true, force: true });
}

if (failures.length > 0) {
	console.error('Lint guardrail check failed:\n' + failures.join('\n'));
	process.exit(1);
}

The scripts and lint-staged hooks live in package.json:

{
	"lint-staged": {
		"*.{js,jsx,ts,tsx}": [
			"oxlint --fix",
			"oxfmt --no-error-on-unmatched-pattern"
		],
		"*.{json,md,css}": [
			"oxfmt --no-error-on-unmatched-pattern"
		]
	},
	"scripts": {
		"lint": "oxlint",
		"lint:fix": "oxlint --fix",
		"lint:rules": "tsx scripts/check-lint-rules.ts",
		"format": "oxfmt .",
		"format:check": "oxfmt --check ."
	}
}

Put lint at the top of CI

I put npm run lint and npm run lint:rules at the top of .github/workflows/pr-quality.yml, right after npm ci. An agent that opens a pull request gets lint results in about 30 seconds. The results cover types, conventions, and repo rules. They arrive before next build starts.

What does not get much faster

Jest still takes about 63 seconds. next build still takes about 90 seconds. Together they still dominate the PR quality job. That is why total CI only dropped 21%, or 69 seconds. I would still make this switch for the lint loop alone.

The repo is still on Jest. The next bottleneck I want to swap out is the test runner, for something faster like Vitest or a Rust-based test runner, so the test step gives the same kind of quick feedback. That keeps a tight, self-interrupting loop when you are vibe coding or working with agents.

I help teams set up strict CI and lint guardrails, and I stabilize React and Next.js codebases on contract or as a fixed-scope codebase health check.

Write to me at https://x.com/adeelibr if you want a deeper breakdown, or book a session to talk shop.

Work together

Need a senior React and JavaScript partner to move faster?

Book a session