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
5 changes: 0 additions & 5 deletions .c8rc.json

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/shiny-llamas-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"htmljs-parser": minor
---

Replace TypeScript enums with erasable const modules so the source runs directly under node's type stripping. The public `TagType`, `ErrorCode`, and `Validity` values keep their runtime shape and values, and their types are now the equivalent literal unions. Constant values remain fully inlined in the published bundles.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

59 changes: 0 additions & 59 deletions .eslintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .fixpackrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [20, 22, 24]
node: [22, 24, 26]
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ dist
*.tsbuildinfo

# Coverage
.nyc_output
coverage
lcov.info
3 changes: 1 addition & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"*.ts": ["eslint --fix", "prettier --write"],
"*{.js,.json,.md,.yml,rc}": ["prettier --write"],
"./package.json": ["fixpack"]
"*{.js,.json,.md,.yml,rc}": ["prettier --write"]
}
6 changes: 0 additions & 6 deletions .mocharc.json

This file was deleted.

6 changes: 0 additions & 6 deletions .nycrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.vscode
.nyc_output
package.json
package-lock.json
CHANGELOG.md
node_modules
Expand Down
10 changes: 2 additions & 8 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"overrides": [
{
"files": "*rc",
"options": {
"parser": "json"
}
}
]
"$schema": "https://json.schemastore.org/prettierrc",
"plugins": ["prettier-plugin-packagejson"]
}
17 changes: 9 additions & 8 deletions bench.mts → bench.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import "./build.mts";
import "./build.ts";

import cp from "child_process";
import degit from "degit";
import fs from "fs/promises";
import { bench, group, run } from "mitata";
import os from "os";
import path from "path";
import fs from "fs/promises";
import cp from "child_process";
import { promisify } from "util";

import degit from "degit";
import { group, bench, run } from "mitata";

const exec = promisify(cp.exec);
const api = (await import("./dist/index.mjs")) as unknown as typeof import("./src");
const api = (await import(
"./dist/index.mjs" as string
)) as unknown as typeof import("./src/index.ts");
const FIXTURES = path.resolve("src/__tests__/fixtures");
const GREP = new RegExp(process.env.GREP || ".", "g");
const COMPARE = process.env.COMPARE;
Expand All @@ -25,7 +26,7 @@ if (COMPARE) {
}

const pkg = JSON.parse(
await fs.readFile(path.join(cwd, "package.json"), "utf-8")
await fs.readFile(path.join(cwd, "package.json"), "utf-8"),
);
compareAPI = await import(
path.join(cwd, pkg.exports?.["."].import ?? pkg.main)
Expand Down
21 changes: 0 additions & 21 deletions build.mts

This file was deleted.

31 changes: 31 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fs from "node:fs/promises";
import path from "node:path";

import { build, type BuildOptions } from "esbuild";

const opts: BuildOptions = {
bundle: true,
outdir: "dist",
platform: "node",
target: ["node14"],
entryPoints: ["src/index.ts"],
minifySyntax: true,
};

await Promise.all([
// The repo root is type=module for the TS sources; mark dist as commonjs
// so the .js bundle and .d.ts files keep their original semantics.
fs.writeFile(
path.join(opts.outdir!, "package.json"),
JSON.stringify({ type: "commonjs" }) + "\n",
),
build({
...opts,
format: "cjs",
}),
build({
...opts,
format: "esm",
outExtension: { ".js": ".mjs" },
}),
]);
37 changes: 37 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import sortImportPlugin from "eslint-plugin-simple-import-sort";
import globals from "globals";
import tseslint from "typescript-eslint";

export default defineConfig(
{
ignores: [".vscode", "coverage", "dist", "**/__snapshots__"],
},
eslint.configs.recommended,
tseslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.node,
},
},
plugins: {
"simple-import-sort": sortImportPlugin,
},
rules: {
"@typescript-eslint/no-duplicate-enum-values": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
},
},
);
Loading
Loading