Skip to content

feat: ship the no-regex-in-tomatchobject eslint rule as a plugin - #68

Merged
Shinrai merged 1 commit into
nextfrom
feat/no-regex-in-tomatchobject
Dec 1, 2026
Merged

Shinrai merged 1 commit into
nextfrom
feat/no-regex-in-tomatchobject

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

  • feat: ship the no-regex-in-tomatchobject eslint rule as a plugin (9e9971d)

🐛 Bug Fixes

No bug fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

No other changes

👥 Contributors

vitest's toMatchObject treats a RegExp in the expected value as matching
anything, so those assertions can never fail. Hoot and quack carried the same
local rule for it; it now ships here as `@cldmv/configs/eslint-plugin.mjs`,
whose `configs.recommended` turns it on for test files:

    import cldmv from "@cldmv/configs/eslint-plugin.mjs";
    export default [...base, cldmv.configs.recommended];

The rule's header cites this repository's issue and no longer lists test
globs, since the recommended block owns them. The package lints its own tests
with it, and the README has a Test rules section.

Resolves #65
@cldmv-bot cldmv-bot Bot added ! feature → next v4 flow: contributor PR targeting the next integration branch type: feature Implements new functionality — a PR or issue that adds a feature area: tests Touches test files, fixtures, or test infrastructure type: dependencies Relates to dependency updates, version bumps, or package management type: documentation Relates to docs, README updates, guides, or inline code comments labels Dec 1, 2026
@Shinrai
Shinrai merged commit dc4fb1b into next Dec 1, 2026
37 checks passed
@cldmv-bot
cldmv-bot Bot deleted the feat/no-regex-in-tomatchobject branch December 1, 2026 16:30
cldmv-bot Bot added a commit that referenced this pull request Dec 1, 2026
# `@cldmv/configs` v1.6.0 Changelog

**Release Date**: December 2026
**Release Type**: Minor
**Branch**: `next` → `master`

---

## Overview

A new `cldmv-configs types` command builds and checks a separate `<pkg>-types` declarations package. With it, a fleet package can move its TypeScript declarations into an optional peer that only TypeScript users install, and keep small re-export stubs in its own `types/stub/`. `types build` writes the stubs and the carved package. `types check` proves that a consumer resolves the declarations and type-checks through both packages.

The package also ships its first ESLint plugin, `@cldmv/configs/eslint-plugin.mjs`, with one rule: `cldmv/no-regex-in-tomatchobject`. It flags a regex inside `toMatchObject(...)`, which Vitest treats as matching anything, so the assertion checks nothing there. One import turns it on for a repository's test files.

The shared configs are unchanged: `fix-headers.json`, `prettier.json`, `prettierignore`, `eslint.config.mjs` and `vitest.config.mjs`. So are `init`, `check` and `sync`. The plugin is opt-in, so nothing changes for a repository until it adds it. The package still has no runtime `engines` field.

---

## ✨ Features

### `cldmv-configs types build` and `types check` ([#64](#64))

```sh
npx cldmv-configs types build   # stubs into types/stub/, the carved package into dist-packages/<pkg>-types/
npx cldmv-configs types check   # resolution checks, then the tsc consumer check
```

Run `types build` after the repository's own `types:build` (`tsc`). The usual wiring is `"build:subpackages": "cldmv-configs types build"` and `"test:types": "cldmv-configs types check"`, both in `build:ci`. Neither command publishes or touches the network; publishing stays in CI.

**`types build`** reads these inputs:

- every `types` target in the root `exports` and `imports`, at any condition depth;
- a required `packaging/<pkg>-types/package.json`;
- an optional `.configs/types-package.json` (`source`, `includeMaps`, `exclude`, `tsc`).

It writes:

- one stub per published target in `types/stub/`, re-exporting the default too when the real declaration has one;
- the carved package in `dist-packages/<pkg>-types/`. Its `package.json` inherits the root's metadata and mirrors the root's typed exports. It lists the root as an optional peer and every package the declarations import by name as a required peer, using the range the root declares.

It never edits the root `package.json`. When a published `types` condition doesn't point at its stub yet, the build fails and prints the path to use. A target that points outside the repository is reported as a problem.

**`types check`** writes nothing in the repository. It checks that:

- every published target points at a stub;
- every stub re-exports a subpath the carved package exports, and its files exist;
- the carved version matches the root's, and the declared peers cover every package the declarations import;
- every import inside the carved declarations resolves.

It then type-checks a generated consumer with the repository's own `typescript`. The consumer imports every typed subpath and runs against the root package (as the files `npm pack` would publish) and the carved package, installed side by side. The runs:

- `nodenext` resolution;
- `bundler` resolution. A package with a `browser` condition runs it with that condition and without `@types/node`;
- a CommonJS consumer, when the package exports a `require` entry;
- one more `nodenext` run per extra condition, such as `deno`.

The consumer project lives in a fresh `cldmv-types-check-*` folder under the system temp folder. That way module resolution can't reach the repository's own `node_modules` and hide a dependency the types package doesn't declare. The folder is removed on every exit path, including SIGINT, SIGTERM and SIGHUP. `tsc.enabled: false` (or `--no-tsc`) skips the type-check, and requires a stated reason.

The README's new [Types packages](https://github.com/CLDMV/configs#-types-packages) section covers every input, output and check.

### `no-regex-in-tomatchobject` lint rule ([#68](#68))

```js
import base from "@cldmv/configs/eslint.config.mjs";
import cldmv from "@cldmv/configs/eslint-plugin.mjs";

export default [...base, cldmv.configs.recommended];
```

`cldmv.configs.recommended` enables `cldmv/no-regex-in-tomatchobject` as an error on `tests/**/*.{js,mjs,cjs}` and `**/*.test.vitest.mjs`. The rule reports a regex literal, `RegExp(...)` or `new RegExp(...)` in the expected value passed to `toMatchObject(...)`, as a property value or an array element, including `rejects`, `resolves` and `not` chains. It doesn't look inside `expect.stringMatching(...)`, `objectContaining(...)` or `arrayContaining(...)`, which compare a regex correctly. Use `expect.stringMatching(...)` or a separate `.toMatch(...)` instead.

The rule moved here from the local copies in hoot and quack, so every repository gets the same version. A repository that carries its own copy can drop it and import the plugin. Fixes [#65](#65).

---

## 🔧 CI & tooling

- `typescript` and `@types/node` are new dev dependencies, used by the `types check` tests. Consumers bring their own `typescript`.
- The repository's own ESLint config uses the new plugin, and coverage now includes `eslint-rules/`.

## 📚 Documentation

- **NEW:** [docs/changelog/v1/v1.6.0.md](https://github.com/CLDMV/configs/blob/v1.6.0/docs/changelog/v1/v1.6.0.md), this changelog.
- README: a Types packages section, a `types` row in the commands table, a Test rules section for the plugin, and the What's New block promoted to v1.6.0.

---

## Upgrade notes

No breaking changes. `types` is a new command and the plugin is opt-in; nothing else in the package changed behaviour. Repositories with a local copy of `no-regex-in-tomatchobject` can replace it with the plugin import above.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-100.0%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 100.0% |
| Branches   | 100.0% |
| Functions  | 100.0% |
| Lines      | 100.0% |

*Avg: **100.0%** · `17c0d48` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Touches test files, fixtures, or test infrastructure ! feature → next v4 flow: contributor PR targeting the next integration branch type: dependencies Relates to dependency updates, version bumps, or package management type: documentation Relates to docs, README updates, guides, or inline code comments type: feature Implements new functionality — a PR or issue that adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant