Skip to content

Comments

chore: add pre-commit hooks + readme/changelog linters, dependency overrides, doc fixes#335

Merged
imantsk merged 27 commits intocore-betafrom
chore/precommit-and-npm-updates
Feb 18, 2026
Merged

chore: add pre-commit hooks + readme/changelog linters, dependency overrides, doc fixes#335
imantsk merged 27 commits intocore-betafrom
chore/precommit-and-npm-updates

Conversation

@imantsk
Copy link
Member

@imantsk imantsk commented Feb 18, 2026

Summary

  • Add Husky + lint-staged pre-commit flow and two repository linters that auto-fix/validate src/readme.txt and CHANGELOG.md.
  • Normalize and auto-fix many documentation-formatting issues; reduce npm audit surface with targeted overrides.
  • Fix a few existing README/CHANGELOG formatting problems and make linting idempotent.

Key changes (high level)

  • Tooling & hooks
    • Added Husky pre-commit hook (.husky/pre-commit) and prepare script in package.json.
    • Added lint-staged config to run file-type checks on staged files.
  • Linters
    • New linters: scripts/linters/lint-readme.ts and scripts/linters/lint-changelog.ts (autofix + validations).
    • Removed old combined scripts/lint-readmes.ts.
  • package.json
    • Scripts: lint:readme, lint:changelog.
    • Added husky, lint-staged devDeps (pinned lint-staged@^15.5.2 for current Node), updated lint-staged config.
    • Added safe overrides for several transitive packages to address vulnerabilities & engine mismatches.
  • Documentation & fixes
    • CONTRIBUTING.md — instructions for hooks.
    • Auto-fixed formatting in src/readme.txt and CHANGELOG.md.
  • Security/deps
    • Ran non-breaking npm audit fix and added targeted overrides (see Risks/Notes).

Behavior / rules enforced

  • readme.txt: canonical WordPress header order/format, section/subsection casing rules, list marker normalization, blank-line rules (scoped for changelog).
  • CHANGELOG.md: release headers normalized to ## [X.Y.Z] (YYYY-MM-DD), ### change-type headings normalized, list marker normalization, spacing rules (1 blank after #/##, no blank after ###), intelligent conversion of indented sublists.
  • Linters are idempotent and auto-stage fixes via lint-staged (hook).

Testing / how to validate locally

  1. Install deps & set up hooks:
    • npm install
    • npm run prepare
  2. Run linters:
    • npm run lint:readme
    • npm run lint:changelog
    • npx lint-staged
  3. Try commit flow:
    • Edit src/readme.txt or CHANGELOG.md, stage and git commit — the hook should auto-fix and re-stage.
  4. Audit / smoke tests:
    • npm audit
    • npm run build / npm test:php / npm run test:playwright

Risks / notes

  • lint-staged pinned to ^15.5.2 to remain compatible with Node v20.16.0 — recommend upgrading Node to >= 20.17 and then moving to lint-staged 16.x.
  • Overrides should be considered temporary; plan to remove them after upstream packages ship fixes.
  • Linters change doc text formatting (safe for readme/changelog), may cause small rebase conflicts.

@imantsk imantsk merged commit 75c9244 into core-beta Feb 18, 2026
8 checks passed
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