Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .c8rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"reporter": ["lcov", "text"],
"extension": [".js"]
}
"include": ["dist/**/*.js"],
"exclude-after-remap": false,
"check-coverage": true,
"statements": 100,
"functions": 100,
"lines": 100,
"branches": 95
}
9 changes: 0 additions & 9 deletions .clintonrc.json

This file was deleted.

9 changes: 1 addition & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
quote_type = single
trim_trailing_whitespace = true
insert_final_newline = true

[{*.json,*.yaml,*.yml,*.jade,*.pss,*.css,*.js,*.md,.*,*.ts}]
indent_size = 2

[{changelog.md,.*}]
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
77 changes: 77 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Contributing

## Development

Use Node.js 24, selected by `.nvmrc`:

```sh
nvm install
nvm use
npm ci
npm run check
```

`check` builds with TypeScript, runs ESLint, checks current and minimum
TypeScript consumers, runs the full suite with coverage, and verifies CommonJS
and native ESM loading. `prepublishOnly` runs the same checks before publication.

- `npm test` rebuilds and runs the suite with coverage.
- `npm run test:unit` tests the existing build with `node:test`.
- `npm run dev` watches TypeScript sources.
- `npm run typecheck:minimum` checks TypeScript 4.3.5 consumers.

Development tools require modern Node.js; the published renderer still supports
Node.js 12 and newer. The parser 0.9 development dependency supplies a round-trip
fixture that also works on the oldest runtime. Current parser integration is
checked through PostHTML's packed-package suite.

## Installed-package checks

After `npm run check`, pack the built output and test it:

```sh
mkdir -p artifacts
npm pack --ignore-scripts --pack-destination artifacts
npm run test:packed -- artifacts/posthtml-render-3.0.0.tgz
```

Use the actual version in the tarball path. `test:packed` installs the production
package in an isolated consumer, runs the complete shared synchronous suite and
CJS/ESM consumers, then compiles standalone TypeScript consumers. Pass
`--node /path/to/node` to run the JavaScript checks with another runtime while
npm and TypeScript remain on Node.js 24. Failed fixtures are preserved for
debugging; `POSTHTML_TEST_TMP` selects their temporary parent directory.

CI builds one tarball on Node.js 24 and tests that artifact on Node.js 12.0,
12/14/16/18/20/22/24/26. Native ESM checks use the historical experimental flag on
Node.js versions before 12.17. Coverage reports are workflow artifacts.

For coordinated changes, follow `AGENTS.md` and run the core packed tests with
`--render /path/to/posthtml-render-<version>.tgz`.

## Changes and pull requests

- Keep commits focused, with short imperative subjects. Prefixes such as `fix:`,
`docs:` and `build:` are optional.
- Include exact-output regression tests for changes to rendering behavior.
- Keep coverage at 100% statements/functions/lines and at least 95% branches.
- Check public declarations against TypeScript 4.3.5 and the current compiler.
- Commit `package-lock.json` with dependency changes. Keep generated `dist/`,
coverage reports, tarballs and temporary consumers out of commits.
- Add user-visible notes to `Unreleased` in `changelog.md`, preserving history.
- Describe verification in the pull request. Checks run in CI and before npm
publication; no local Git hooks are installed.

## Releases

1. Prepare a release pull request. Update the version and lockfile with
`npm version <version> --no-git-tag-version`.
2. Turn `Unreleased` into a dated version entry and start a new `Unreleased`
section above it. Maintain the changelog by hand.
3. Run `npm run check`, test the tarball and validate it in PostHTML.
4. Merge the release pull request after its checks pass. Tag the tested master
commit as `v<version>` and publish that checkout with `npm publish`.
5. Verify the npm version/dist-tag and a fresh registry install before updating
the renderer dependency range in core.

Publishing and pushing release tags require an explicit maintainer request.
32 changes: 10 additions & 22 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
> ✏️ Briefly describe the issue you are experiencing (or the feature you want to see added to the plugin). Tell us what you were trying to do and what happened instead. Remember, this is _not_ a place to ask questions. For that, go to http://gitter.im/posthtml/posthtml
## Description

### `Details`
What happened, and what output did you expect?

> ✏️ Describe in more detail the problem you have been experiencing, if necessary.
## Reproduction

## `Error (Logs|Stacks)`
Include the input tree or HTML, renderer options, and a minimal runnable example.

> 👉 Create a [gist](https://gist.github.com) which is a paste of your **full** logs, and link them here.
## Environment

> ⚠️ Do **not** paste your full logs here (or at least hide them by using a `<details></details>` block), as it will make this issue long and hard to read! If you are reporting a bug, **always** include logs!
- posthtml-render version:
- Node.js version:
- Operating system:

### `Reproduction (Code)`
## Logs

> ⚠️ Please remember that, with sample code; it's easier to reproduce a bug and much faster to fix it.

> 🔗 Please refer to a simple code example.

```bash
$ git clone https://github.com/<user>/<sample>
```

### `Environment`

> ℹ️ Please provide information about your current environment.

|OS|node|npm/yarn|package|
|:-:|:--:|:-:|:------:|
|[name][version]|[version]|[version]|[version]|
Include relevant errors or stack traces, if any.
57 changes: 7 additions & 50 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,12 @@
### `Notable Changes`
## Summary

> ✏️ Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue down below.
Describe the change and link any related issues.

#### `Commit Message Summary (CHANGELOG)`
## Compatibility

```
commit message body...
```
Describe changes to output, options, declarations or supported runtimes, if any.

### `Type`
## Verification

> ℹ️ What types of changes does your code introduce?

> 👉 _Put an `x` in the boxes that apply and delete all others_

- [ ] CI
- [ ] Fix
- [ ] Perf
- [ ] Docs
- [ ] Test
- [ ] Chore
- [ ] Style
- [ ] Build
- [ ] Feature
- [ ] Refactor

### `SemVer`

> ℹ️ What changes to the current `semver` range does your PR introduce?

> 👉 _Put an `x` in the boxes that apply and delete all others_

- [ ] Fix (:label: Patch)
- [ ] Feature (:label: Minor)
- [ ] Breaking Change (:label: Major)

### `Issues`

> ℹ️ What issue(s) (if any) are closed by your PR?

> 👉 _Replace `#1` with the issue number that applies and remove the ``` ` ```_

- Fixes `#1`

### `Checklist`

> ℹ️ You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. This is a reminder of what we are going to look for before merging your code.

> 👉 _Put an `x` in the boxes that apply and delete all others._

- [ ] Lint and unit tests pass with my changes
- [ ] I have added tests that prove my fix is effective/works
- [ ] I have added necessary documentation (if appropriate)
- [ ] Any dependent changes are merged and published in downstream modules
List the checks performed, including `npm run check`, tarball tests and any
cross-package integration checks relevant to this change.
85 changes: 58 additions & 27 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,70 @@
name: Actions Status
name: build

on:
push:
branches: [master]
pull_request:
types: [opened, synchronize]
branches:
- master
env:
CI: true
types: [opened, synchronize, reopened]
branches: [master]
workflow_dispatch:

permissions:
contents: read

jobs:
run:
name: Node ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
check:
name: Build and check (Node 24)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7.1.0
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm run check
- name: Upload coverage
uses: actions/upload-artifact@v7.0.2
with:
name: coverage
path: coverage/lcov.info
if-no-files-found: error
- name: Pack the checked build
run: |
mkdir artifacts
npm pack --ignore-scripts --pack-destination artifacts
- uses: actions/upload-artifact@v7.0.2
with:
name: npm-package
path: artifacts/*.tgz
if-no-files-found: error

runtime:
name: Packed runtime Node ${{ matrix.node }}
needs: check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [12, 14, 16]
os: [ubuntu-latest]

node: ['12.0.0', '12', '14', '16', '18', '20', '22', '24', '26']
steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set Node.js version
uses: actions/setup-node@v1
- uses: actions/checkout@v7.0.1
- name: Select the consumer runtime
uses: actions/setup-node@v7.1.0
with:
node-version: ${{ matrix.node }}

- name: Install npm dependencies
run: npm ci

- name: Run tests
run: npm run test

- name: Run Coveralls
uses: coverallsapp/github-action@master
- name: Record the consumer executable
id: runtime-path
run: echo "node=$(node -p process.execPath)" >> "$GITHUB_OUTPUT"
- name: Use development Node for npm and TypeScript
uses: actions/setup-node@v7.1.0
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci --ignore-scripts
- uses: actions/download-artifact@v8.0.2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
name: npm-package
path: artifacts
- name: Run the complete suite and consumers against the tarball
run: npm run test:packed -- "artifacts/posthtml-render-$(node -p 'require("./package.json").version').tgz" --node "${{ steps.runtime-path.outputs.node }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
coverage
.nyc_output
npm-debug.log
dist
dist
artifacts
*.tgz
6 changes: 0 additions & 6 deletions .huskyrc

This file was deleted.

3 changes: 0 additions & 3 deletions .lintstagedrc

This file was deleted.

6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
Loading
Loading