noctcore-code-quality/no-focused-tests
Rule id
noctcore-code-quality/no-focused-tests
- Package
- code-quality v1.0.0
- Preset
- recommended
- Severity
- error
- Autofix
- No
- Suggestions
- Yes
- Options
- None
- Type info
- Not needed
Ban .only / fdescribe / fit so a focused test never silently lands in CI.
A focused test (it.only, fdescribe, …) silences the rest of the suite. Committed by accident it
turns a green CI run into a lie — the suite “passes” because almost none of it ran. This rule makes a
focused test a lint error so it can’t merge.
What it flags
Section titled “What it flags”.onlyresolved back to ait/describe/testrunner, including chained modifiers (test.concurrent.only,describe.concurrent.only).- The Jest/Jasmine focused-call forms
fdescribe(...),fit(...),ddescribe(...)— but only as a bare-identifier callee, so an unrelatedobj.fit(...)method is not flagged.
it.only('runs', () => {});test.concurrent.only('case', () => {});fdescribe('suite', () => {});it('runs', () => {});layout.fit('contain'); // not a test runnerSuggestion
Section titled “Suggestion”Reports offer an editor suggestion (not an autofix, so --fix never undoes a focus you are using
mid-debug) that removes .only, or replaces fit / fdescribe / ddescribe with it / describe.
What it does not flag
Section titled “What it does not flag”.onlyon something that is not a test runner (queue.only(...),db.batch.only(...)), and a plain variable namedonly.- A method named
fiton some object (layout.fit('contain')): only the bare global counts. .onlyread as a value rather than called (RuleTester.itOnly = it.only): nothing is focused.- Skipped tests (
it.skip,xit): seeskipped-tests-need-tracking.
When not to use it
Section titled “When not to use it”You almost always want this on. Disable only in throwaway scratch suites.