@boring-stack-pkg/eslint-plugin-test-conventions
v0.1.2
Published
ESLint rules that catch the most common test-suite mistakes: focused tests, direct DB access from tests, and orphaned test files.
Downloads
2,266
Maintainers
Readme
eslint-plugin-test-conventions
ESLint rules that catch the most common test-suite mistakes:
no-focused-tests—test.only/it.only/fdescribe/fitleft in committed code. The single.onlythat turns CI green by skipping everything else.no-direct-db-in-tests— tests reaching into the DB driver directly, bypassing the helpers entrypoint where you do connection probing, isolation, and cleanup.test-file-mirrors-source— orphaned*.test.tsfiles left behind after a refactor, still passing, still giving you false confidence in code that no longer exists.
Install
pnpm add -D @boring-stack-pkg/eslint-plugin-test-conventionsPeer deps: eslint >= 8.57, @typescript-eslint/parser >= 8,
typescript >= 5.
Use (flat config)
import tsParser from "@typescript-eslint/parser";
import testConventions from "@boring-stack-pkg/eslint-plugin-test-conventions";
export default [
{
files: ["**/*.{ts,tsx}"],
languageOptions: { parser: tsParser },
plugins: { "test-conventions": testConventions },
rules: {
"test-conventions/no-focused-tests": "error",
"test-conventions/no-direct-db-in-tests": "error",
"test-conventions/test-file-mirrors-source": "error",
},
},
];Or use the bundled config:
import testConventions from "@boring-stack-pkg/eslint-plugin-test-conventions";
export default [testConventions.configs.recommended];Rules
| Rule | Description | Fixable |
| -------------------------------------------------------------------- | ------------------------------------------------------ | ------- |
| no-focused-tests | Disallow .only and bare aliases (fdescribe, fit) | – |
| no-direct-db-in-tests | Tests must go through the helpers entrypoint | – |
| test-file-mirrors-source | Every test file must mirror an existing source file | – |
License
MIT.
