@noctcore/eslint-plugin-code-quality
A bad fit if your team writes explanatory step-by-step comments on purpose.
Guard clauses, comment hygiene, test discipline and deterministic time.
What it solves
Section titled “What it solves”A grab bag with one theme: code and tests that stay honest over time. Focused and silently skipped tests, assertions that can never fail, fake timers that leak into the next test, unit tests that hit the real network, comments that narrate or reference a PR number that means nothing in a year, Date.now() scattered through business logic.
What it will yell at you about
Section titled “What it will yell at you about”It will yell at you about tests and comments more than about runtime code. The comment rules (no-narration-comments, no-historical-comments, no-pr-reference-comments) are opinionated and will fire on a lot of existing code; that is the point, but expect a cleanup pass. no-bare-date-now assumes you read time through a shared clock. The test rules match on method names, so they cover Jest, Vitest and Bun alike. It is a bad fit if your team writes explanatory step-by-step comments on purpose. interface-prefix-i and no-template-trim-empty-ternary are exported but left out of the preset: they are house style, not correctness.
Install and configure
Section titled “Install and configure”npm install --save-dev @noctcore/eslint-plugin-code-quality @typescript-eslint/parser# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-code-quality @typescript-eslint/parserThe recommended preset enables 12 of 21 rules. The strict preset adds 2 house rules (naming, folder shape, size caps) on top. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.
Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first
read is no-conditional-expect.
--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.
useFakeTimers() must also call useRealTimers(), so fake timers do not leak into later tests.I followed by an uppercase letter. Module/global augmentations are exempt.Date.now() / new Date() in business logic. Read wall-clock time through a shared clock util (nowMs() / now()) so time is mockable.expect() inside a branch, catch or loop that may not run: a skipped assertion lets a broken test pass.toThrow() with no argument or with only a message: any error passes, including a TypeError from a broken mock. Pin the error class.process.exit() outside bootstrap/shutdown paths and standalone CLIs. Application and service code must throw or reject so the lifecycle can shut down gracefully.Date.now(), new Date()) unless the file fakes it; an offset from now (Date.now() + 60_000) is allowed.new Promise((r) => setTimeout(r, n)), timers/promises): fake the timers or wait for the condition.try whose catch neither rethrows nor asserts, and .catch() handlers that swallow an expect(...).rejects/.resolves failure: the assertion fails, the error is dropped, and the test passes.<template>.trim() === '' ? fallback : <template>.trim() patterns. Extract to a named utility so the expression is built once and is unit-testable in one place.typeof checks, literal tautologies, a sole toBeDefined/toBeTruthy, a sole presence check on the render root): a test must assert behaviour that a real regression would break.if without an else.expect(page.url()), expect(await page.title())): the check runs once, possibly before the navigation lands. Use the retrying toHaveURL / toHaveTitle..skip / .fixme / xit / xdescribe, and unconditional node:test { skip } / { todo } / t.skip()) must carry a tracking marker (an issue URL or TODO(@owner)) on or above the line, so the debt has an owner instead of rotting silently.jest.fn() / vi.fn() mocks cast as unknown as T: the double cast switches type checking off, so a mock of a renamed or removed method keeps passing.