test-sibling-enforcement
test-sibling-enforcement
- Package
- lint-meta-rules v1.1.0
- Runs under
@noctcore/harnesslint-meta, not ESLint- Factory
createTestSiblingEnforcementRule- Entry point
@noctcore/lint-meta-rules- Category
source-text- Fails CI by default
- Yes
Every source file matched by include must have a colocated sibling test.
A pure helper with no test is a silent liability — the kind of code that drifts because nothing pins
its behavior. Requiring a colocated test for a chosen class of files (.utils.ts helper files, say)
makes “did you test this?” a mechanical check rather than a review-time hope.
What it flags
Section titled “What it flags”For each file matched by an include glob, the sibling test is the same path with its .ts/.tsx
extension replaced by each configured test extension. If none of those siblings exists, the source
file is flagged. Strict — there is no baseline; the pattern is opt-in via which files include selects.
What it does not flag
Section titled “What it does not flag”- A matched file with a sibling for any one of
testExtensions(foo.utils.test.tsorfoo.utils.test.tsxforfoo.utils.ts). - Files outside
include(onlyapps/web/src/**/*.utils.tsby default).
Options
Section titled “Options”createTestSiblingEnforcementRule(options?: TestSiblingEnforcementOptions): IMetaRule| Option | Type | Default | Meaning |
|---|---|---|---|
include |
string[] |
['apps/web/src/**/*.utils.ts'] |
Source files that must ship a colocated test. |
testExtensions |
string[] |
['.test.ts', '.test.tsx'] |
Accepted colocated-test extensions (replace the source extension). |
ciCritical |
boolean |
true |
Whether a violation fails CI. |
When not to use it
Section titled “When not to use it”If you colocate tests loosely or centralize them in a __tests__ tree, retune include/testExtensions
or skip the rule.
This rule only checks that the test file exists, not that anything runs it: a sibling named
.utils.test.ts under a runner that includes only *.test.tsx passes here and never executes.
Pair it with test-file-matches-runner-include, which
reports a test file no runner collects.