Repository navigation
feat: ship the no-regex-in-tomatchobject eslint rule as a plugin - #68
Merged
Merged
Conversation
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
Shinrai
approved these changes
Dec 1, 2026
This was referenced Dec 1, 2026
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 -->  | 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
🐛 Bug Fixes
No bug fixes
📦 Dependencies
No dependency updates
🔧 Other Changes
No other changes
👥 Contributors