Zero-tolerance ESLint plugin and config for enforcing strict code quality standards in TypeScript projects.
Now supports ESLint 8.57+ (legacy config) and ESLint 9.x/10.x with Flat Config
Documentation:
- Hosted docs: https://coderrob.github.io/eslint-config-zero-tolerance/
- Repository docs fallback:
docs/index.md - Rules index fallback:
docs/rules/index.md
This monorepo contains two packages:
@coderrob/eslint-plugin-zero-tolerance- ESLint plugin with custom rules@coderrob/eslint-config-zero-tolerance- ESLint config that exports recommended and strict presets
- ESLint 8.57.0+, 9.x, or 10.x
- TypeScript-ESLint 8.x
- TypeScript 5.x
npm install --save-dev @coderrob/eslint-plugin-zero-tolerance @typescript-eslint/parserUsing the recommended preset:
// eslint.config.js
import zeroTolerance from '@coderrob/eslint-plugin-zero-tolerance';
export default [
zeroTolerance.configs.recommended,
// your other configs...
];Using the strict preset:
// eslint.config.js
import zeroTolerance from '@coderrob/eslint-plugin-zero-tolerance';
export default [
zeroTolerance.configs.strict,
// your other configs...
];Alternative: Import presets directly from the config package:
// eslint.config.js
import recommended from '@coderrob/eslint-config-zero-tolerance/recommended';
// or
import strict from '@coderrob/eslint-config-zero-tolerance/strict';
export default [
recommended, // or strict
// your other configs...
];Custom configuration:
// eslint.config.js
import zeroTolerance from '@coderrob/eslint-plugin-zero-tolerance';
export default [
{
plugins: {
'zero-tolerance': zeroTolerance,
},
rules: {
'zero-tolerance/require-interface-prefix': 'error',
'zero-tolerance/no-throw-literal': 'error',
'zero-tolerance/max-function-lines': ['warn', { max: 40 }],
// ... other rules
},
},
];Using .eslintrc.js:
module.exports = {
plugins: ['zero-tolerance'],
extends: ['plugin:zero-tolerance/legacy-recommended'],
// or for strict mode:
// extends: ['plugin:zero-tolerance/legacy-strict'],
};Nearly all core rules are included in the recommended (warn) and strict (error) presets. prefer-result-return and require-jsdoc-anonymous-functions are enabled at warn in the strict preset only. require-bdd-spec and no-parent-internal-access are fully opt-in rules (off in all presets).
no-parent-internal-access is a targeted boundary rule: it only checks parent-relative paths and only matches the first concrete directory reached after .. traversal, such as ../src/foo.
| Rule | Description |
|---|---|
require-interface-prefix |
Enforce that TypeScript interface names start with I followed by an uppercase letter |
| Rule | Description |
|---|---|
require-bdd-spec |
Enforce that every TypeScript source file has a valid sibling .ts.bdd.json BDD spec |
require-jsdoc-anonymous-functions |
Require JSDoc comments on anonymous function-like constructs except test files and known test callbacks |
require-jsdoc-functions |
Require JSDoc comments on named functions (except test files) |
require-optional-chaining |
Require optional chaining instead of repeated guard access |
require-readonly-props |
Require JSX component props to be typed as readonly |
| Rule | Description |
|---|---|
require-test-description-style |
Enforce that test descriptions start with should |
no-jest-have-been-called |
Prohibit imprecise call-assertion matchers; use toHaveBeenCalledTimes and toHaveBeenNthCalledWith instead |
no-mock-implementation |
Prohibit persistent mock methods; use Once variants to prevent test bleeds |
| Rule | Description |
|---|---|
no-type-assertion |
Prevent use of TypeScript as and angle-bracket assertions |
no-non-null-assertion |
Disallow non-null assertions using the ! postfix operator |
no-literal-unions |
Ban literal union types in favour of enums |
no-banned-types |
Ban ReturnType and indexed access types |
no-inline-type-import |
Disallow inline import("...").Type annotations |
no-destructured-parameter-type-literal |
Disallow inline object type literals on destructured parameters |
require-exported-object-type |
Require exported object constants to declare an explicit type annotation |
| Rule | Description |
|---|---|
max-function-lines |
Enforce a maximum number of lines per function body |
max-params |
Enforce a maximum number of function parameters |
no-array-mutation |
Disallow mutating array methods |
no-date-now |
Disallow Date.now() and no-arg new Date() usage |
no-magic-numbers |
Disallow magic numbers; use named constants instead |
no-magic-strings |
Disallow magic strings in comparisons and switch cases |
no-object-mutation |
Disallow direct object-property mutation |
sort-imports |
Require import declarations to be grouped and alphabetized |
sort-functions |
Require top-level functions to be sorted alphabetically |
prefer-nullish-coalescing |
Prefer nullish coalescing instead of repeated nullish guard ternaries |
prefer-readonly-parameters |
Prefer readonly typing for object and array-like parameters |
prefer-string-raw |
Prefer String.raw for strings containing escaped backslashes |
| Rule | Description |
|---|---|
no-empty-catch |
Disallow empty catch blocks that silently swallow errors |
no-throw-literal |
Disallow throwing literals, objects, or templates; always throw a new Error instance |
prefer-result-return |
Prefer returning Result-style values instead of throwing |
| Rule | Description |
|---|---|
require-clean-barrel |
Require barrel files (index.*) to contain only module re-exports |
no-barrel-parent-imports |
Ban .. and ../* parent-directory import traversal in barrel files |
no-parent-internal-access |
Ban parent-relative access into protected internal directories such as src |
no-dynamic-import |
Ban dynamic import() and require() outside test files |
no-export-alias |
Prevent use of aliases in export statements |
no-re-export |
Disallow direct or pass-through re-export statements from parent/grandparent modules |
| Rule | Description |
|---|---|
no-identical-expressions |
Disallow identical expressions on both sides of a binary or logical operator |
no-identical-branches |
Disallow identical branches in if/else and ternary conditionals |
no-boolean-return-trap |
Disallow ambiguous boolean-return APIs outside predicate naming |
no-redundant-boolean |
Disallow redundant comparisons to boolean literals |
no-for-in |
Disallow for..in loops |
no-labels |
Disallow labeled statements |
no-with |
Disallow with statements |
no-await-in-loop |
Disallow await inside loops; use Promise.all() instead |
no-floating-promises |
Disallow unhandled promise expressions; require explicit handling |
no-eslint-disable |
Prevent use of eslint-disable comments |
no-parameter-reassign |
Disallow reassigning function parameters |
no-flag-argument |
Disallow boolean flag parameters in function signatures |
prefer-guard-clauses |
Prefer guard clauses by removing else blocks after terminating if branches |
prefer-shortcut-return |
Prefer shortcut boolean returns over if branches that return true/false |
no-query-side-effects |
Disallow side effects in query-style functions |
This repository itself is a pnpm workspace. Use pnpm install at the repo root; npm install examples above are for consuming the published packages in another project, not for bootstrapping this monorepo.
pnpm installpnpm buildpnpm testThis also refreshes the coverage badge in README.md using coverage output in packages/plugin/coverage/.
Coverage gates are enforced in CI with a minimum of 95% on:
- statements
- branches
- functions
- lines
The repository lints itself using its own plugin rules through eslint.config.mjs.
pnpm eslint packages/plugin/src/rulespnpm --filter @coderrob/eslint-plugin-zero-tolerance exec tsc -p tsconfig.json --noEmit
pnpm --filter @coderrob/eslint-config-zero-tolerance exec tsc -p tsconfig.json --noEmitpnpm deps:graph
pnpm deps:circularThis monorepo provides automated scripts to handle versioned releases.
Quick release (single command):
pnpm release:prepare --release patch --commit --tag --publishThis will:
- bump the root, plugin, and config package versions
- replace
workspace:*with a versioned peer dependency inpackages/config - run
pnpm buildandpnpm test - create a release commit and annotated git tag
- publish both packages to npm
If you want to restore workspace:* after publishing for local development, run:
pnpm release:restore-workspaceOr include --restore-workspace and commit that restoration separately.
Manual/stepwise release flow:
# 1. Build all packages
pnpm build
# 2. Run tests to ensure everything works
pnpm test
# 3. Prepare packages for publishing (converts workspace:* to versioned dependency)
pnpm release:prepare
# 4. Publish the plugin package
cd packages/plugin
npm publish
# 5. Publish the config package
cd ../config
npm publish
# 6. Restore workspace:* for local development
cd ../..
pnpm release:restore-workspaceAdditional release:prepare options:
# Bump versions and prepare manifests without publishing
pnpm release:prepare --release minor
# Skip build/test if already run in CI or a previous step
pnpm release:prepare --release 1.2.0 --skip-build --skip-test --commit --tag --publish
# Dry run the full flow
pnpm release:prepare --release patch --commit --tag --publish --dry-runApache 2.0 Copyright Robert Lindley