Repository navigation
feat: add cldmv-configs types build and check for @cldmv/<pkg>-types packages - #64
Merged
Merged
Conversation
…packages `cldmv-configs types build` writes one re-export stub per published types target to types/stub/ and carves the declarations into dist-packages/<pkg>-types/ (package.json inherited from the root, the packaging/<pkg>-types manifest and computed exports/imports/files/peer, plus LICENSE and README), then runs the repo's own fix-headers over it. It never edits the root package.json; it checks that the published types conditions already point at the stubs. `cldmv-configs types check` verifies the stubs, the carved exports and the #imports resolve, then type-checks a generated consumer with the repo's own typescript (nodenext with @types/node, bundler without). Skipping tsc needs a stated reason. Neither command publishes or touches the network. Adds typescript 6 and @types/node as devDependencies for the tsc tests.
…s a browser condition A Node package's declarations can use Node's types (Buffer, NodeJS.ReadableStream), and dropping @types/node from the bundler run failed them for no reason. Only a package that declares a browser condition promises declarations that work without Node's globals, so that one runs bundler with the browser condition and without @types/node.
Contributor
Author
|
Auto-normalized PR title: rewrote PR title to match the highest-priority commit type (
If this isn't what you want, edit the title. The normalizer leaves it alone as long as it stays conventional, ranks at least as high as the commits' type, and its summary matches one of the commit subjects. |
- Detect a re-exported default (`export { default } from`), so its stub keeps the default line.
- Refuse published types targets outside the repository, and never pick a source folder from one; an absolute target used to hang the source search.
- Count an imports entry that points straight at a declaration file as type-only.
- Packages the declarations import become required peers of the types package with the root's range; one the root doesn't depend on is a problem, and check flags a carved package missing one.
- The consumer check now runs in a temp project outside the repository, installs the root as the files npm pack would publish (a stub left out of files fails), links only the carved package's peers, adds a CommonJS consumer when the package exports require, runs once per extra types condition, and never deletes through a link it couldn't remove.
… on a signal The project lives in os.tmpdir() under a cldmv-types-check- prefix, a deliberate exception to the repository tmp/ convention: resolving under the repository would walk into its node_modules and hide a dependency the types package doesn't declare. Cleanup now also runs on SIGINT, SIGTERM and SIGHUP, a tsc run stopped by a signal ends the check, and tests prove the folder is gone after a failing check and after SIGTERM.
Shinrai
approved these changes
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
📦 Dependencies
No dependency updates
🔧 Other Changes
No other changes
👥 Contributors