npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

oxc-config-ai-guardrails

v1.2.0

Published

AI guardrails for the oxc toolchain: strict oxlint presets and an oxfmt profile that keep AI-generated code small, flat and functional

Readme

oxc-config-ai-guardrails

Strict oxlint presets and an oxfmt profile that keep AI-generated code small, flat and honest about its types.

npm version oxlint license

🚀 Quick start · 📦 Presets · 🛡️ Rules · ❓ FAQ · 🤝 Contributing


A coding agent writes code that compiles and looks finished. It also writes 300-line functions, nested if blocks, any parameters, module mocks that hide the real code, and TODO comments that nobody returns to. This package makes oxlint reject those patterns, so the agent must fix them before you review the code.

  • ✅ 92 rules, each one proven to fire. npm run verify lints deliberate violations and fails if a rule stays silent.
  • ⚡ Native oxlint only. There are no ESLint plugins and no jsPlugins. The package has 2 peer dependencies.
  • 💬 Comments go on their own line. A comment after code on the same line fails. Placeholder comments (TODO, FIXME, XXX, HACK), blanket disable comments and @ts-ignore also fail.

👀 Example

An agent writes this:

export async function loadUsers(ids: string[], cache: any) {
  const users = [];
  for (let i = 0; i < ids.length; i++) {
    const user = await fetch(`/api/users/${ids[i]}`).then((r) => r.json());
    if (user) {
      // TODO: handle inactive users
      users.push(Reflect.get(user, 'profile'));
    }
  }
  return users;
}

oxlint with the base preset rejects it (the output below is shortened):

1:8   error  eslint(func-style): Expected a function expression.
1:23  error  typescript(explicit-module-boundary-types): Missing return type on function
1:48  error  typescript(explicit-module-boundary-types): Argument is explicitly typed as `any`
1:55  error  typescript(no-explicit-any): Unexpected `any`. Specify a different type.
3:35  error  eslint(no-plusplus): Unary operator '++' used.
4:18  error  eslint(no-await-in-loop): Unexpected `await` inside a loop.
5:5   error  eslint(max-depth): Blocks are nested too deeply (2). Maximum allowed is 1.
6:7   error  eslint(no-warning-comments): Unexpected 'todo' comment: TODO: handle inactive users
7:18  error  eslint(no-restricted-properties): 'Reflect.get' is restricted from being used.

🚀 Quick start

1. Install

npm i -D oxlint oxfmt oxc-config-ai-guardrails

Add oxlint-tsgolint only if you want the type-aware preset:

npm i -D oxlint-tsgolint

2. Configure oxlint

.oxlintrc.json:

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "extends": [
    "./node_modules/oxc-config-ai-guardrails/configs/base.json",
    "./node_modules/oxc-config-ai-guardrails/configs/typescript.json",
    "./node_modules/oxc-config-ai-guardrails/configs/react.json"
  ],
  "options": {
    "reportUnusedDisableDirectives": "error"
  }
}

reportUnusedDisableDirectives reports disable comments that no longer suppress anything. oxlint reads it only from your root config, so the presets cannot set it for you.

Or oxlint.config.ts:

import { defineConfig } from 'oxlint';
import { base, react, typescript } from 'oxc-config-ai-guardrails';

export default defineConfig({
  extends: [base, typescript, react],
  options: { reportUnusedDisableDirectives: 'error' },
});

3. Configure oxfmt

oxfmt has no extends, so import the profile from oxfmt.config.ts:

import { defineConfig } from 'oxfmt';
import { oxfmt } from 'oxc-config-ai-guardrails';

export default defineConfig(oxfmt);

4. Add scripts

{
  "scripts": {
    "lint": "oxlint",
    "lint:types": "oxlint --type-aware",
    "fmt": "oxfmt",
    "fmt:check": "oxfmt --check"
  }
}

📦 Presets

| Preset | Contents | Needs | |---|---|---| | configs/base.json | 71 syntax rules, plus the correctness, suspicious and perf categories for the core, typescript, unicorn, import, oxc, vitest and promise plugins | oxlint | | configs/typescript.json | 17 type-aware rules | oxlint-tsgolint and --type-aware | | configs/react.json | 4 React rules, the jsx-a11y plugin, and a 100-line budget for .tsx and .jsx functions | oxlint | | configs/oxfmt.json | 120 columns, single quotes, sorted imports | oxfmt |

Use only the presets that you need. For a Node project with no React, leave out react.json.

base and typescript relax their noisiest rules in *.test.*, *.spec.*, test/, tests/ and __tests__/ files.

🛡️ What the rules enforce

📏 Size budgets

| Rule | Limit | Test files | |---|---|---| | max-lines | 200 lines for each file | off | | max-lines-per-function | 50 lines (100 in .tsx/.jsx) | off | | max-statements | 20 for each function | off | | max-params | 3 | on | | max-depth | 1 level of nested blocks | on | | complexity | 10 | on | | max-nested-callbacks | 2 | off |

Blank lines do not count against the line limits.

no-else-return (also bans else if), no-lonely-if, no-nested-ternary, no-continue, no-labels, no-plusplus, no-void, curly, no-await-in-loop, no-loop-func, guard-for-in, no-fallthrough.

A ternary is legal. A ternary inside a ternary is not.

func-style (expressions only), prefer-arrow-callback, arrow-body-style, no-var, prefer-const, no-param-reassign (properties too), max-classes-per-file: 0, oxc/no-this-in-exported-function.

Test files can declare classes.

| Rule | Rejects | |---|---| | typescript/no-explicit-any | any | | typescript/no-non-null-assertion | value! | | typescript/ban-ts-comment | @ts-ignore, @ts-nocheck, and @ts-expect-error without a description | | typescript/explicit-module-boundary-types | exported functions without parameter and return types | | typescript/no-restricted-types | object, Record<string, unknown> and Record<string, any> | | typescript/no-empty-object-type | {}, which accepts every non-nullish value | | typescript/consistent-indexed-object-style | { [key: string]: T }, rewritten to Record so the rule above can check it | | no-restricted-properties | Reflect.get and Reflect.apply, which turn an unsound access into any | | typescript/no-unsafe-* (type-aware) | values of type any that move through calls, assignments and returns | | typescript/no-unsafe-type-assertion (type-aware) | as casts that the compiler cannot prove |

| Rule | Rejects | |---|---| | vitest/no-restricted-vi-methods | vi.mock, vi.doMock and vi.stubGlobal. The rule follows import aliases. | | no-restricted-properties | jest.mock, jest.retryTimes and Playwright page.waitForTimeout | | vitest/no-conditional-in-test | if, switch and ?: in a test body | | vitest/no-large-snapshots | inline snapshots longer than 50 lines | | vitest/padding-around-test-blocks, vitest/padding-around-after-all-blocks | a test or afterAll block with no blank line before it |

A module mock or a stubbed global hides the real dependency, so a test can pass while the code is broken. Inject the dependency instead. A retry or a fixed wait hides a flaky test.

The vitest plugin also turns on its correctness and suspicious rules, for example no-disabled-tests, expect-expect, no-conditional-expect and require-to-throw-message. These rules also check Jest test files.

no-restricted-properties matches identifier names, so an aliased jest or page is not caught.

  • Syntax: promise/prefer-await-to-then (use await, not .then() chains), eqeqeq (== null stays legal), no-throw-literal, array-callback-return. The promise plugin also turns on its correctness and suspicious rules, for example no-multiple-resolved.
  • Type-aware: typescript/no-floating-promises, typescript/no-misused-promises, typescript/await-thenable, typescript/require-await, typescript/switch-exhaustiveness-check, typescript/no-unnecessary-condition, typescript/no-unnecessary-type-assertion, typescript/prefer-nullish-coalescing, typescript/prefer-optional-chain, typescript/no-deprecated, typescript/no-implied-eval.
  • Imports: import/no-cycle, import/no-duplicates, import/first, import/newline-after-import, import/no-namespace, import/no-mutable-exports, typescript/consistent-type-imports.
  • Modern APIs: 11 unicorn rules, for example prefer-at, prefer-array-find, prefer-includes, prefer-number-properties and throw-new-error. Also prefer-exponentiation-operator.
  • Safety: no-eval, no-new-func, no-script-url, oxc/no-async-endpoint-handlers.
  • Comments: no-inline-comments bans a comment after code on the same line. Bundler annotations such as /* @__PURE__ */ stay legal. Other tool comments on the same line, for example /* webpackChunkName: "x" */, need // oxlint-disable-next-line no-inline-comments. no-warning-comments bans TODO, FIXME, XXX and HACK. unicorn/no-abusive-eslint-disable bans oxlint-disable and eslint-disable comments that do not name a rule.

react/rules-of-hooks, react/exhaustive-deps, react/no-unstable-nested-components, react/no-array-index-key.

The jsx-a11y plugin turns on its accessibility rules, for example alt-text, click-events-have-key-events and no-static-element-interactions. react/react-in-jsx-scope is off, because the JSX transform of React 17 and later does not need React in scope.

❓ FAQ

Rules in your own config override the extended presets:

{
  "extends": ["./node_modules/oxc-config-ai-guardrails/configs/base.json"],
  "rules": {
    "max-lines": ["error", { "max": 300, "skipBlankLines": true }],
    "no-continue": "off"
  }
}

typescript/explicit-module-boundary-types treats an exported component like every other exported function. The props type and the return type are the public contract of the component:

export const Button = ({ label }: Props): ReactElement => <button>{label}</button>;

The rule does not check .js and .jsx files, or functions that you do not export.

oxlint has two traps:

  1. A bare rule key can resolve to a type-aware rule. no-implied-eval exists only as a tsgolint rule, so it never runs without --type-aware. This package keeps it in configs/typescript.json for that reason.
  2. oxlint ignores unknown rule options. A typo in an option does not fail the run. Write a file that must fail, and check that oxlint reports it.

🤝 Contributing

Every rule must fire on a fixture. The verify script enforces this:

npm install
npm run verify

scripts/verify.mjs lints fixtures/ and checks these claims:

  1. Every rule in its manifest is in a preset, and every enabled rule is in the manifest.
  2. Every rule in the manifest fires on a fixture.
  3. Each plugin that adds only category rules (vitest, promise, jsx-a11y) loads: one of its category rules fires.
  4. The test-file overrides relax what they promise, and prefer-const still fires in the same file.
  5. An 85-line component passes, a 110-line component fails, and a 51-line non-JSX function fails.
  6. 3 prose comments after code fail. Bundler annotations, == null and a plain ternary stay legal.
  7. Each fixture that claims 4 to 6 use has at least one diagnostic, so a broken filename match fails.

To add a rule:

  1. Add it to a file in configs/.
  2. Add it to MANIFEST in scripts/verify.mjs.
  3. Add a fixture in fixtures/ that breaks the rule.
  4. Run npm run verify.

The files in fixtures/ are deliberate rule violations. Do not copy them.

📄 License

MIT