Skip to content

feat: add cldmv-configs types build and check for @cldmv/<pkg>-types packages - #64

Merged
Shinrai merged 4 commits into
nextfrom
feat/types-carve
Dec 1, 2026
Merged

Shinrai merged 4 commits into
nextfrom
feat/types-carve

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

No other changes

👥 Contributors

…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.
@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: cli Touches CLI / executable / bin entry points 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 Nov 30, 2026
@cldmv-bot cldmv-bot Bot changed the title fix: keep @types/node in the bundler check unless the package declares a browser condition feat: add cldmv-configs types build and check for @cldmv/<pkg>-types packages Nov 30, 2026
@cldmv-bot

cldmv-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Auto-normalized PR title: rewrote PR title to match the highest-priority commit type (feat).

  • Before: fix: keep @types/node in the bundler check unless the package declares a browser condition
  • After: feat: add cldmv-configs types build and check for @cldmv/<pkg>-types packages

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
Shinrai merged commit e938936 into next Dec 1, 2026
34 checks passed
@cldmv-bot
cldmv-bot Bot deleted the feat/types-carve branch December 1, 2026 03:48
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: cli Touches CLI / executable / bin entry points 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