Skip to content

Version Packages - #59

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
changeset-release/main
Open

github-actions[bot] wants to merge 1 commit into
mainfrom
changeset-release/main

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@noctcore/eslint-plugin-code-quality@0.4.0

Minor Changes

  • #53 954f5b2 Thanks @Shironex! - Four new opt-in test-discipline rules and two stricter existing rules.

    A project that spreads recommended sees new errors from two rules it already runs:

    • no-vacuous-expect now reports a test whose only assertion is that the render root is present (soleRenderRootExpect): expect(container).not.toBeEmptyDOMElement(), expect(container.firstChild).toBeInTheDocument(), expect(container.innerHTML).not.toBe('') and the like, on a container or baseElement bound from a call (const { container } = render(...), view.container, render(...).container). Such a test passes for anything that renders, an error fallback included. Assert on a role, a label or a text instead, or set the new renderRoots option to [] to keep the old behaviour.
    • skipped-tests-need-tracking now also reads node:test skips: a skip or todo option whose value is a truthy literal ({ skip: true }, { skip: 'reason' }, { todo: 1 }) on test / it / describe / suite (and a t.test subtest), and t.skip() / t.todo() (awaited or not) as a statement of the test callback's own body. Only unconditional skips are reported: a computed value ({ skip: process.platform === 'win32' }, { skip: !ready }) or a t.skip(...) inside an if is a platform guard and stays silent. Add an issue URL or TODO(@owner) near the skip, as for .skip(.

    New rules, left out of recommended (each needs a per-project fact; enabling them is up to you):

    • no-message-only-throw-assertion: toThrow() / toThrowError() with no argument, or with only a string, template or regex, and the message snapshots toThrowErrorMatchingSnapshot() / toThrowErrorMatchingInlineSnapshot(), sync or after .rejects. Any error passes those, including a TypeError from a broken mock. A class argument, an asymmetric matcher, .rejects.toMatchObject(...) and .not.toThrow() are fine, and a message-only assertion is accepted when the same test pins the class of the same subject in the same or an enclosing block (a bare toThrow() is never excused that way). Options: throwMatchers, allowMessageOnly (report only the argless form), trustErrorInstances (set false under Jest, where toThrow(new X('m')) and .rejects.toEqual(new X('m')) compare only the message; a .rejects.toMatchObject({ message }) or toHaveProperty('message') is never a class pin) and assertionHelpers.
    • no-sleep-in-unit-tests: a real sleep in a unit test file: new Promise((r) => setTimeout(r, n)), setTimeout from timers/promises, and promisify(setTimeout). A zero or omitted delay (allowZeroDelay, on by default) a reject-only timeout guard and a deadline whose kept handle the file passes to clearTimeout are not sleeps, and a file that installs fake timers (fakeTimerMethods, default useFakeTimers) is not checked, since its waits are virtual. Same testFileSuffixes / integrationMarkers options as no-real-network-in-unit-tests.
    • no-real-clock-in-unit-tests: Date.now(), an argless new Date() and Date() in a unit test file that never fakes the clock (useFakeTimers, setSystemTime, a Date.now spy, a stubbed or replaced global Date, or a mocked module matching clockModules). An offset from now (Date.now() + 60_000, new Date().getTime() - 1000) is allowed.
    • typed-mock-over-double-cast: an object literal containing jest.fn() / vi.fn() cast as unknown as T (or through any or never, in as or angle-bracket form). Type it as jest.Mocked<Pick<T, ...>> or check it with satisfies. Options: mockFactories, allowTargets for types too wide to Pick from.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants