Skip to content

Commit 347c38e

Browse files
committed
chore: align source style and development runners
Consolidates the original contiguous commits c489c45..383c08b. Preserves the exact tree at the end of this group.
1 parent 29003f0 commit 347c38e

43 files changed

Lines changed: 3271 additions & 1996 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.config/README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Code style
2+
3+
Run `pnpm format`, `pnpm lint`, and `pnpm type` before submitting changes.
4+
Formatting and linting share their file list in `scripts/lib/tooling-scope.mts`.
5+
Generated JavaScript and upstream fixtures are excluded.
6+
7+
Use two spaces, single quotes, no semicolons, and regex literals for static
8+
patterns. Lint checks correctness, suspicious code, imports, and TypeScript.
9+
Use default imports for `node:path`, `node:crypto`, and `node:os`.
10+
11+
Package scripts use `scripts/run.mts` to share an OS-temporary Node compile cache
12+
with child processes. Existing cache settings and opt-outs are preserved.
13+
Coverage runs disable the cache for accurate measurements.
14+
The launcher permits pnpm, aube, and direct Node runs. Other package managers
15+
receive a pnpm command to run instead. Published package consumers are unaffected.
16+
17+
The runtime keeps older syntax and compiler conventions. The adapter uses inline
18+
type imports so its build remains CommonJS. Extension property quotes prevent the
19+
build from introducing object shorthand into ES5 output. Build tests enforce
20+
these compatibility requirements.
21+
22+
Type assertions remain allowed while the runtime and host declarations are
23+
incrementally typed. Promise checks remain enabled.

‎.config/oxfmt.json‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
11
{
2+
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxfmt/configuration_schema.json",
3+
"useTabs": false,
24
"tabWidth": 2,
35
"printWidth": 80,
46
"singleQuote": true,
7+
"jsxSingleQuote": false,
8+
"quoteProps": "as-needed",
59
"trailingComma": "all",
610
"semi": false,
7-
"arrowParens": "avoid"
11+
"arrowParens": "avoid",
12+
"bracketSameLine": false,
13+
"bracketSpacing": true,
14+
"singleAttributePerLine": false,
15+
"overrides": [
16+
{
17+
"files": ["**/src/modules/*.mts"],
18+
"options": { "quoteProps": "preserve" }
19+
}
20+
],
21+
"jsdoc": {
22+
"addDefaultToDescription": false,
23+
"bracketSpacing": false,
24+
"capitalizeDescriptions": true,
25+
"commentLineStrategy": "multiline",
26+
"descriptionTag": false,
27+
"descriptionWithDot": true,
28+
"keepUnparsableExampleIndent": false,
29+
"lineWrappingStyle": "balance",
30+
"preferCodeFences": false,
31+
"separateReturnsFromParam": false,
32+
"separateTagGroups": true
33+
}
834
}

‎.config/oxlint.json‎

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"typeAware": true,
44
"denyWarnings": true
55
},
6-
"plugins": ["oxc", "import", "typescript"],
6+
"plugins": ["oxc", "typescript", "unicorn", "import"],
77
"categories": {
8-
"correctness": "error"
8+
"correctness": "error",
9+
"suspicious": "error"
910
},
1011
"env": {
1112
"node": true,
@@ -16,12 +17,114 @@
1617
"NW": "readonly"
1718
},
1819
"rules": {
20+
"typescript/no-unsafe-type-assertion": "off",
21+
"eslint/complexity": ["error", 15],
22+
"eslint/curly": "error",
23+
"eslint/no-await-in-loop": "off",
24+
"eslint/no-console": "off",
25+
"eslint/no-control-regex": "off",
26+
"eslint/no-empty": [
27+
"error",
28+
{
29+
"allowEmptyCatch": true
30+
}
31+
],
32+
"eslint/no-new": "error",
33+
"eslint/no-proto": "error",
34+
"eslint/no-shadow": "error",
35+
"eslint/no-underscore-dangle": "off",
36+
"eslint/no-unmodified-loop-condition": "off",
37+
"eslint/no-unused-vars": [
38+
"error",
39+
{
40+
"args": "all",
41+
"argsIgnorePattern": "^_",
42+
"varsIgnorePattern": "^$",
43+
"caughtErrors": "all",
44+
"caughtErrorsIgnorePattern": "^_",
45+
"destructuredArrayIgnorePattern": "^_",
46+
"ignoreRestSiblings": false
47+
}
48+
],
49+
"eslint/no-useless-catch": "off",
50+
"eslint/no-var": "error",
51+
"eslint/prefer-const": "error",
52+
"eslint/prefer-regex-literals": [
53+
"error",
54+
{
55+
"disallowRedundantWrapping": true
56+
}
57+
],
58+
"eslint/preserve-caught-error": "off",
59+
"eslint/sort-imports": "off",
60+
"import/no-cycle": "off",
61+
"import/no-named-as-default": "off",
62+
"import/no-named-as-default-member": "off",
63+
"import/no-self-import": "error",
64+
"import/no-unassigned-import": "off",
65+
"typescript/array-type": [
66+
"error",
67+
{
68+
"default": "array-simple"
69+
}
70+
],
71+
"typescript/consistent-type-assertions": [
72+
"error",
73+
{
74+
"assertionStyle": "as"
75+
}
76+
],
77+
"typescript/consistent-type-imports": "error",
78+
"typescript/no-duplicate-enum-values": "error",
79+
"typescript/no-duplicate-type-constituents": [
80+
"error",
81+
{
82+
"ignoreUnions": true
83+
}
84+
],
85+
"typescript/no-explicit-any": "error",
86+
"typescript/no-extra-non-null-assertion": "error",
87+
"typescript/no-extraneous-class": "off",
88+
"typescript/no-misused-new": "error",
89+
"typescript/no-non-null-asserted-optional-chain": "off",
90+
"typescript/no-redundant-type-constituents": "off",
91+
"typescript/no-this-alias": [
92+
"error",
93+
{
94+
"allowDestructuring": true
95+
}
96+
],
97+
"typescript/no-unnecessary-type-assertion": "off",
98+
"typescript/no-useless-empty-export": "error",
99+
"typescript/no-wrapper-object-types": "error",
100+
"typescript/prefer-as-const": "error",
101+
"typescript/triple-slash-reference": "error",
102+
"unicorn/consistent-function-scoping": "off",
103+
"unicorn/no-array-for-each": "off",
104+
"unicorn/no-array-reverse": "error",
105+
"unicorn/no-array-sort": "error",
106+
"unicorn/no-empty-file": "off",
107+
"unicorn/no-null": "off",
108+
"unicorn/no-useless-fallback-in-spread": "off",
109+
"unicorn/numeric-separators-style": "error",
110+
"unicorn/prefer-node-protocol": "error",
111+
"unicorn/prefer-spread": "off",
19112
"no-console": "off",
20113
"typescript/no-floating-promises": "error",
21114
"typescript/no-misused-promises": "error",
22115
"typescript/await-thenable": "error"
23116
},
24117
"overrides": [
118+
{
119+
"files": ["**/src/dom-selector.mts"],
120+
"rules": { "typescript/consistent-type-imports": "off" }
121+
},
122+
{
123+
"files": ["**/*.mts", "**/*.ts"],
124+
"rules": {
125+
"eslint/no-unused-vars": "off"
126+
}
127+
},
25128
{
26129
"files": ["**/src/**/*.mts"],
27130
"rules": {
@@ -35,7 +138,17 @@
35138
"default-case": "error",
36139
"no-duplicate-case": "error",
37140
"radix": "error",
38-
"no-with": "error"
141+
"no-with": "error",
142+
"eslint/no-var": "off",
143+
"eslint/block-scoped-var": "off",
144+
"unicorn/numeric-separators-style": "off",
145+
"typescript/no-unnecessary-boolean-literal-compare": "off",
146+
"typescript/no-unnecessary-type-conversion": "off",
147+
"typescript/unbound-method": "off",
148+
"eslint/prefer-const": "off",
149+
"eslint/complexity": "off",
150+
"eslint/no-shadow": "off",
151+
"typescript/no-explicit-any": "off"
39152
}
40153
}
41154
]

‎.config/runtime.d.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface NwsapiEngine {
1+
export interface NwsapiEngine {
22
S_BODY: string
33
M_BODY: string
44
S_TEST: string
@@ -31,4 +31,3 @@ declare global {
3131
}
3232
const define: { (factory: unknown): void; amd?: unknown }
3333
}
34-
export {}

‎.config/tsconfig.check.json‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@
1414
"forceConsistentCasingInFileNames": true,
1515
"strict": false
1616
},
17-
"include": ["../src/**/*.mts", "../scripts/**/*.mts", "../test/*.mts", "../test/upstream/*.mts", "./*.mts", "./*.d.ts"]
17+
"include": [
18+
"../src/**/*.mts",
19+
"../scripts/**/*.mts",
20+
"../test/*.mts",
21+
"../test/upstream/*.mts",
22+
"./*.mts",
23+
"./*.d.ts"
24+
]
1825
}

‎.config/vitest.config.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default defineConfig({
1717
isolate: true,
1818
maxWorkers: 4,
1919
restoreMocks: true,
20-
testTimeout: 10000,
20+
testTimeout: 10_000,
2121
coverage: {
2222
provider: 'v8',
2323
include: ['src/*.js'],

‎package.json‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,28 @@
8787
}
8888
},
8989
"scripts": {
90-
"ci:local": "local-ci run --workflow .github/workflows/node.js.yml --quiet --pause-on-failure --github-token",
91-
"clean": "node scripts/clean.mts",
92-
"lint": "node scripts/lint.mts",
93-
"format": "oxfmt --config .config/oxfmt.json scripts test/*.test.mts test/jsdom-adapter-package.mts test/upstream/*.mts .config/*.mts .config/*.d.ts",
94-
"format:check": "oxfmt --check --config .config/oxfmt.json scripts test/*.test.mts test/jsdom-adapter-package.mts test/upstream/*.mts .config/*.mts .config/*.d.ts",
95-
"build": "node scripts/build.mts",
96-
"min": "node scripts/build.mts",
97-
"prepack": "node scripts/build.mts",
98-
"serve": "node scripts/serve.mts",
99-
"test": "vitest run --config .config/vitest.config.mts",
100-
"type": "tsc --noEmit -p .config/tsconfig.check.json",
101-
"test:node": "vitest run --config .config/vitest.config.mts",
102-
"test:watch": "vitest --watch --config .config/vitest.config.mts",
103-
"test:coverage": "node scripts/coverage.mts",
104-
"gen:coverage": "node scripts/gen/coverage-badge.mts",
105-
"check:coverage": "node scripts/gen/coverage-badge.mts --check",
106-
"test:package": "node test/jsdom-adapter-package.mts",
107-
"test:upstream": "node scripts/build.mts && playwright test --config .config/playwright.config.mts",
108-
"upstream:clone": "node scripts/git-partial-submodule.mts clone",
109-
"upstream:verify": "node scripts/git-partial-submodule.mts verify",
110-
"test:attributes": "vitest run --config .config/vitest.config.mts test/attribute-parse-error.test.mts",
111-
"test:attributes:browser": "NWSAPI_BROWSER=1 vitest run --config .config/vitest.config.mts test/attribute-strings-browser.test.mts",
112-
"test:browser": "NWSAPI_BROWSER=1 vitest run --config .config/vitest.config.mts"
90+
"ci:local": "node scripts/run.mts node_modules/run-local-ci/dist/native-launcher.js run --workflow .github/workflows/node.js.yml --quiet --pause-on-failure --github-token",
91+
"clean": "node scripts/run.mts scripts/clean.mts",
92+
"lint": "node scripts/run.mts scripts/lint.mts",
93+
"format": "node scripts/run.mts scripts/format.mts",
94+
"format:check": "node scripts/run.mts scripts/format.mts --check",
95+
"build": "node scripts/run.mts scripts/build.mts",
96+
"min": "node scripts/run.mts scripts/build.mts",
97+
"prepack": "node scripts/run.mts scripts/build.mts",
98+
"serve": "node scripts/run.mts scripts/serve.mts",
99+
"test": "node scripts/run.mts node_modules/vitest/vitest.mjs run --config .config/vitest.config.mts",
100+
"type": "node scripts/run.mts node_modules/typescript/bin/tsc --noEmit -p .config/tsconfig.check.json",
101+
"test:node": "node scripts/run.mts node_modules/vitest/vitest.mjs run --config .config/vitest.config.mts",
102+
"test:watch": "node scripts/run.mts node_modules/vitest/vitest.mjs --watch --config .config/vitest.config.mts",
103+
"test:coverage": "node scripts/run.mts scripts/coverage.mts",
104+
"gen:coverage": "node scripts/run.mts scripts/gen/coverage-badge.mts",
105+
"check:coverage": "node scripts/run.mts scripts/gen/coverage-badge.mts --check",
106+
"test:package": "node scripts/run.mts test/jsdom-adapter-package.mts",
107+
"test:upstream": "node scripts/run.mts scripts/build.mts && node scripts/run.mts node_modules/@playwright/test/cli.js test --config .config/playwright.config.mts",
108+
"upstream:clone": "node scripts/run.mts scripts/git-partial-submodule.mts clone",
109+
"upstream:verify": "node scripts/run.mts scripts/git-partial-submodule.mts verify",
110+
"test:attributes": "node scripts/run.mts node_modules/vitest/vitest.mjs run --config .config/vitest.config.mts test/attribute-parse-error.test.mts",
111+
"test:attributes:browser": "NWSAPI_BROWSER=1 node scripts/run.mts node_modules/vitest/vitest.mjs run --config .config/vitest.config.mts test/attribute-strings-browser.test.mts",
112+
"test:browser": "NWSAPI_BROWSER=1 node scripts/run.mts node_modules/vitest/vitest.mjs run --config .config/vitest.config.mts"
113113
}
114114
}

‎scripts/coverage.mts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { execFileSync } from 'node:child_process'
22
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
3-
import { tmpdir } from 'node:os'
3+
import os from 'node:os'
44
import path from 'node:path'
55
import { pathToFileURL } from 'node:url'
66
import { convert } from 'ast-v8-to-istanbul'
@@ -19,7 +19,7 @@ import {
1919
const { createCoverageMap } = libCoverage
2020
const { createContext } = libReport
2121

22-
const raw = mkdtempSync(path.join(tmpdir(), 'nwsapi-wpt-coverage-'))
22+
const raw = mkdtempSync(path.join(os.tmpdir(), 'nwsapi-wpt-coverage-'))
2323
const run = (entry, args, env = process.env) =>
2424
execFileSync(process.execPath, [entry, ...args], {
2525
cwd: REPO_ROOT,
@@ -44,8 +44,9 @@ try {
4444
const entries = JSON.parse(
4545
readFileSync(path.join(raw, `${i}.json`), 'utf8'),
4646
)
47-
if (!entries.length)
47+
if (!entries.length) {
4848
throw new Error(`Missing WPT coverage: ${manifest[i].path}`)
49+
}
4950
for (const entry of entries) {
5051
coverage.merge(
5152
await convert({
@@ -70,7 +71,9 @@ try {
7071
dir: path.join(REPO_ROOT, 'coverage'),
7172
coverageMap: combined,
7273
})
73-
for (const name of coverageReporters()) reports.create(name).execute(context)
74+
for (const name of coverageReporters()) {
75+
reports.create(name).execute(context)
76+
}
7477
checkCoverageThresholds(combined.getCoverageSummary())
7578
run('scripts/gen/coverage-badge.mts', [])
7679
} finally {

‎scripts/format.mts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { execFileSync } from 'node:child_process'
2+
import { globSync } from 'node:fs'
3+
import { REPO_ROOT } from './lib/paths.mts'
4+
import { toolingFiles } from './lib/tooling-scope.mts'
5+
6+
execFileSync(
7+
process.execPath,
8+
[
9+
'node_modules/oxfmt/bin/oxfmt',
10+
'--config',
11+
'.config/oxfmt.json',
12+
...toolingFiles(),
13+
...globSync('.config/*.json', { cwd: REPO_ROOT }),
14+
...process.argv.slice(2),
15+
],
16+
{ cwd: REPO_ROOT, stdio: 'inherit' },
17+
)

‎scripts/gen/coverage-badge.mts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env node
2-
/** Generate or check the README coverage badge from the latest coverage run. */
2+
/**
3+
* Generate or check the README coverage badge from the latest coverage run.
4+
*/
35

46
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
57
import path from 'node:path'

0 commit comments

Comments
 (0)