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
7 changes: 7 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"all": true,
"extension": [".ts"],
"include": ["src/**/*.ts"],
"exclude-after-remap": true,
"reporter": ["lcov", "text"]
}
21 changes: 0 additions & 21 deletions .eslintrc.json

This file was deleted.

41 changes: 41 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing

## Development

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

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

`npm run check` builds the package, runs ESLint, checks the current and minimum supported TypeScript versions, runs tests with coverage, and verifies CommonJS/native ESM loading.

For a focused run, `npm run test:unit` tests the existing build. `npm test` rebuilds it and collects coverage.

## Commits and pull requests

- Keep each commit focused on one change. Use a short, imperative subject that explains the change; prefixes such as `fix:`, `docs:`, and `build:` are useful but optional.
- Include regression tests when changing parser behavior. Explain intentional AST or option changes in the pull request.
- Update `changelog.md` under `Unreleased` for user-visible changes, including Node.js or TypeScript requirements.
- Commit `package-lock.json` with dependency changes. Generated `dist/`, coverage reports, and temporary `consumer/` installs are build artifacts.
- Run `npm run check` before opening a pull request and describe the verification performed.

CI runs the checks on Node.js 24, builds one npm tarball, then installs its production dependencies and runs the full parser suite across the runtime matrix. Coverage reports are available as workflow artifacts. Runtime support follows the parser dependency chain; development-tool requirements do not set the runtime minimum.

## Releases

The changelog is maintained by hand so release notes and historical entries are preserved.

1. Prepare a release pull request. For the next breaking 0.x release, update the package and lockfile without creating a commit or tag:

```sh
npm version 0.13.0 --no-git-tag-version
```

2. Turn the `Unreleased` notes into a versioned, dated entry and start a new `Unreleased` section above it, keeping the previous history intact.
3. Run `npm run check` and commit the version files and changelog together.
4. After the release pull request is merged, update `master`, tag the release commit as `v0.13.0`, and push the tag.
5. Publish that checkout with `npm publish`. The `prepublishOnly` script runs the full check again before publishing.
10 changes: 0 additions & 10 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: posthtml
open_collective: posthtml
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Summary

<!-- What changed and why? -->

## Verification

<!-- List the checks run, including npm run check. -->

## Compatibility

<!-- Describe changes to parsing, options, AST, or Node.js/TypeScript support, if any. -->
82 changes: 59 additions & 23 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,57 @@ env:
CI: true

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:
- name: Clone repository
uses: actions/checkout@v7.0.1

- name: Set Node.js version
uses: actions/setup-node@v7.1.0
with:
node-version-file: .nvmrc
cache: npm

- name: Install npm dependencies
run: npm ci

- name: Build, lint, check types and run tests
run: npm run check

- name: Upload coverage report
uses: actions/upload-artifact@v7.0.2
with:
name: coverage
path: |
coverage/lcov.info
coverage/lcov-report/
if-no-files-found: error

- name: Pack npm artifact
run: |
mkdir artifacts
npm pack --ignore-scripts --pack-destination artifacts

- name: Upload npm artifact
uses: actions/upload-artifact@v7.0.2
with:
name: npm-package
path: artifacts/*.tgz
if-no-files-found: error

runtime:
name: Runtime Node ${{ matrix.node }}
needs: check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [20.19.0, 22.12.0, 22, 24, 26]
os: [ubuntu-latest]
env:
POSTHTML_PARSER_PACKAGE: ${{ github.workspace }}/consumer/node_modules/posthtml-parser

steps:
- name: Clone repository
Expand All @@ -31,27 +73,21 @@ jobs:
uses: actions/setup-node@v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm

- name: Install npm dependencies
run: npm ci

- name: Run lint
run: npm run lint
- name: Download npm artifact
uses: actions/download-artifact@v8.0.2
with:
name: npm-package
path: artifacts

- name: Check types
run: npm run typecheck
- name: Install production package
run: |
mkdir consumer
node -e 'require("node:fs").writeFileSync("consumer/package.json", JSON.stringify({ private: true }))'
npm install --prefix consumer --ignore-scripts --omit=dev "$GITHUB_WORKSPACE"/artifacts/*.tgz

- name: Run tests
run: npm run test
- name: Run all parser tests against the installed package
run: npm run test:unit

- name: Check package loading
- name: Check CommonJS and ESM loading
run: npm run test:package

- name: Run Coveralls
if: matrix.node == 24
uses: coverallsapp/github-action@v2.3.8
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
file: coverage/lcov.info
format: lcov
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
consumer
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-push

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.

8 changes: 2 additions & 6 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"$schema": "https://json.schemastore.org/prettierrc",
"bracketSpacing": true,
"endOfLine": "lf",
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 120,
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderGroupNamespaceSpecifiers": true,
"importOrderCaseInsensitive": true
"printWidth": 120
}
11 changes: 10 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@

* With `decodeEntities: true`, entities in `textarea` content are now decoded, consistent with other text content. Previously `htmlparser2` left them encoded in this case.

### Development

* Use the built-in Node.js test runner and assertions, with c8 for source coverage.
* Compile JavaScript, declarations, and source maps directly with TypeScript.
* Update ESLint to flat config and document contributing and releases in `.github`.
* Remove local Git hooks, commit-message linting, and changelog generation dependencies; maintain release notes by hand.
* Store coverage reports as GitHub Actions artifacts.
* Build and check on Node.js 24, then run the full test suite against an installed npm tarball on every supported runtime.
* Run the full check before publishing.

## <small>0.12.1 (2024-09-19)</small>

* build(deps-dev): bump braces from 3.0.2 to 3.0.3 ([5faad33](https://github.com/posthtml/posthtml-parser/commit/5faad33))
Expand Down Expand Up @@ -390,4 +400,3 @@
* add package.json ([3daf4bc](https://github.com/posthtml/posthtml-parser/commit/3daf4bc))
* basic ([2e38720](https://github.com/posthtml/posthtml-parser/commit/2e38720))
* Initial commit ([285d87f](https://github.com/posthtml/posthtml-parser/commit/285d87f))

21 changes: 21 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

const typescriptFiles = ["**/*.ts", "**/*.cts", "**/*.mts"];

export default [
{ ignores: ["dist/**", "coverage/**", "artifacts/**", "consumer/**"] },
js.configs.recommended,
...tseslint.configs.recommended.map((config) => ({
...config,
files: typescriptFiles,
})),
{
files: ["test/types/*.cts"],
rules: {
"@typescript-eslint/no-require-imports": ["error", { allowAsImport: true }],
},
},
{ languageOptions: { globals: globals.node } },
];
Loading
Loading