Skip to content

chore: modernize coding style, lint and type tooling (no behavior cha… - #439

Merged
modesty merged 2 commits into
masterfrom
scratch/lintFormatType
Nov 6, 2026
Merged

modesty merged 2 commits into
masterfrom
scratch/lintFormatType

Conversation

@modesty

@modesty modesty commented Nov 6, 2026

Copy link
Copy Markdown
Owner

…nge)

Lint (eslint.config.js)

  • Rewrite on defineConfig/globalIgnores with one shared rule set.
  • ESM files see only Node built-in globals; .cjs files get CommonJS globals. Tests and bin/ are now linted.
  • Fix no-unused-vars so unused arguments are reported; parameters kept for arity use a leading "_".
  • TypeScript uses typescript-eslint strictTypeChecked and stylisticTypeChecked with projectService.
  • Enforce private-member conventions: no "#_x", no TS private modifier, no leading-underscore members (Node stream hooks exempt).

Formatting

  • Add Prettier 3.9.10 (.prettierrc.json, .prettierignore): tabs, double quotes, semicolons, 120 columns, chosen as the lowest-churn options.
  • Remove the unused .prettierrc.cjs and reformat all JS/TS sources.

Source idioms

  • "#_x" -> "#x" in lib/; TS private -> "#" in src/cli/.
  • var -> const/let, Object.hasOwn, Number.isNaN/Number.isFinite, for...of Object.entries, arrow functions in place of .bind(this), and object spread in place of Object.assign({}, ...).
  • PDFParser._PARSER_SIG keeps its public name for back-compat and now reads the shared PARSER_SIG from lib/pkinfo.js.

TypeScript

  • Upgrade 5.9.3 -> 6.0.3; typescript-eslint supports TS <6.1.
  • tsconfig: module/moduleResolution nodenext, target/lib es2024, verbatimModuleSyntax, erasableSyntaxOnly, noImplicitOverride.
  • Type the CLI's PDFParser members and settle-result types (type-only changes).

Scripts and CI

  • Add lint:fix, format, format:check and typecheck scripts. The build now runs lint, format check and typecheck before bundling.
  • CI: run on push to master, bump action majors, Deno 2.9.8, Node 22.23.2, add typecheck and format-check steps, and add a non-blocking TypeScript 7 typecheck.

Docs

  • AGENTS.md: code-quality commands and lint-enforced conventions.
  • readme: lint/format/typecheck section; build-before-test note replaces the removed pretest step; the command-line test section now uses the real p2j.*.sh scripts and npm run test:forms/test:misc; the exception-test counts are now 22 files, 16 pass, 6 expected failures, with the current file names.

…nge)

Lint (eslint.config.js)
- Rewrite on defineConfig/globalIgnores with one shared rule set.
- ESM files see only Node built-in globals; .cjs files get CommonJS
  globals. Tests and bin/ are now linted.
- Fix no-unused-vars so unused arguments are reported; parameters kept
  for arity use a leading "_".
- TypeScript uses typescript-eslint strictTypeChecked and
  stylisticTypeChecked with projectService.
- Enforce private-member conventions: no "#_x", no TS `private`
  modifier, no leading-underscore members (Node stream hooks exempt).

Formatting
- Add Prettier 3.9.10 (.prettierrc.json, .prettierignore): tabs, double
  quotes, semicolons, 120 columns, chosen as the lowest-churn options.
- Remove the unused .prettierrc.cjs and reformat all JS/TS sources.

Source idioms
- "#_x" -> "#x" in lib/; TS `private` -> "#" in src/cli/.
- var -> const/let, Object.hasOwn, Number.isNaN/Number.isFinite,
  for...of Object.entries, arrow functions in place of .bind(this),
  and object spread in place of Object.assign({}, ...).
- PDFParser._PARSER_SIG keeps its public name for back-compat and now
  reads the shared PARSER_SIG from lib/pkinfo.js.

TypeScript
- Upgrade 5.9.3 -> 6.0.3; typescript-eslint supports TS <6.1.
- tsconfig: module/moduleResolution nodenext, target/lib es2024,
  verbatimModuleSyntax, erasableSyntaxOnly, noImplicitOverride.
- Type the CLI's PDFParser members and settle-result types (type-only
  changes).

Scripts and CI
- Add lint:fix, format, format:check and typecheck scripts. The build
  now runs lint, format check and typecheck before bundling.
- CI: run on push to master, bump action majors, Deno 2.9.8,
  Node 22.23.2, add typecheck and format-check steps, and add a
  non-blocking TypeScript 7 typecheck.

Docs
- AGENTS.md: code-quality commands and lint-enforced conventions.
- readme: lint/format/typecheck section; build-before-test note
  replaces the removed pretest step; the command-line test section now
  uses the real p2j.*.sh scripts and npm run test:forms/test:misc; the
  exception-test counts are now 22 files, 16 pass, 6 expected failures,
  with the current file names.
On a clean checkout dist/ does not exist yet. The checks ran before
build:bundle-pdfjs-base copies dist/pdfparser.d.ts, so type-aware lint
could not resolve the CLI's ../../dist/pdfparser.js import and failed
with 61 errors on both CI runners.

- Restore build:bundle-pdfjs-base to the plain bundle script.
- Add a check script (lint, format:check, typecheck); build now runs
  bundle-pdfjs-base, then check, then rollup.
- Add .gitattributes (eol=lf) so Windows checkouts are LF and the
  Prettier check passes on every OS.
- CI: fold the separate lint, typecheck and format-check steps into
  Build; keep the non-blocking TypeScript 7 trial.
- readme: note that build runs the checks.
@modesty
modesty merged commit 5edaa03 into master Nov 6, 2026
2 checks passed
@modesty
modesty deleted the scratch/lintFormatType branch November 6, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant