Skip to content

Tooling: Make lint:pkg-json and lint:md:docs lint real files - #631

Open
huzaifaalmesbah wants to merge 1 commit into
WordPress:developfrom
huzaifaalmesbah:fix/npm-lint-pkg-json-md-docs
Open

huzaifaalmesbah wants to merge 1 commit into
WordPress:developfrom
huzaifaalmesbah:fix/npm-lint-pkg-json-md-docs

Conversation

@huzaifaalmesbah

Copy link
Copy Markdown
Member

What?

Points the lint:pkg-json and lint:md:docs scripts at the repository's real files and fixes the errors they report.

Why?

Fixes #630. Follow-up to #629.

Both scripts targeted ./src, which has no package.json and no Markdown files, so they always passed without linting anything.

How?

lint:pkg-json → wp-scripts lint-pkg-json .

  • . checks the root package.json and the storybook workspace. The default wp-scripts ignore file already skips node_modules, vendor, build and wordpress.
  • package.json: reordered properties to match @wordpress/npm-package-json-lint-config (author and license before keywords; homepage, repository, bugs and engines moved up; devDependencies before scripts). No values changed.
  • storybook/package.json: added description, author, license, keywords, homepage, repository (with directory) and bugs; marked it "private": true because it's an internal workspace that is never published; sorted devDependencies; moved scripts after peerDependencies.
  • package-lock.json: one-line update for the workspace's new license field (from npm install --package-lock-only).

lint:md:docs → wp-scripts lint-md-docs README.md CONTRIBUTING.md \".github/*.md\" \"storybook/stories/**/*.md\"

  • The globs use escaped double quotes so they work on Windows. LICENSE.md (the GPL text) is left out. The default wp-scripts ignore still skips node_modules, vendor and build.
  • Content fixes: wrapped bare URLs in <> and dropped $ prompts in README.md; added a blank > line before the list in CONTRIBUTING.md; indented nested lists to 4 spaces in database-schema.md; added php and text fence languages and a final newline in translations.md.
  • Added .markdownlint.json, which extends the wp-scripts default config and changes three rules:
    • MD024 siblings_only: develop.md has two "Running PHP unit tests" headings under different parent sections, which is intentional.
    • MD033 allows <details> and <summary>: the updated PR template in GitHub: Update the pull request template #625 uses them.
    • MD041 off: .github/PULL_REQUEST_TEMPLATE.md starts with an HTML comment by design. Adding a disable directive there would appear in every PR body.

Note: the fix for #629 also edits the scripts block in package.json. Whichever of the two PRs merges second will need a small rebase.

Testing Instructions

  1. Run npm ci.
  2. Run npm run lint:pkg-json. It exits 0.
  3. Run npm run lint:md:docs. It exits 0 with no findings.
  4. Remove "license" from storybook/package.json and run npm run lint:pkg-json. It reports require-license and exits with a non-zero code. Revert the change.
  5. Append a nested list item indented by 2 spaces (- a, then - b on the next line) to README.md, .github/PULL_REQUEST_TEMPLATE.md or storybook/stories/docs/contributors/develop.md, then run npm run lint:md:docs. It reports MD007 and exits with code 1. Revert the change.

Screenshots or screencast

N/A

Use of AI Tools
  • AI assistance: Yes
  • Tool(s): Claude Code
  • Model(s): Claude Opus 5.5
  • Used for: Finding the scripts that lint nothing, updating the script targets, fixing the lint findings, and checking that the scripts pass and still catch deliberately introduced errors. I reviewed and tested all changes.

Both scripts targeted ./src, which has no package.json and no Markdown
files, so they always passed without checking anything.

- lint:pkg-json now lints the root and storybook package.json files.
  Reorder properties and add the missing metadata to the storybook
  workspace, which is marked private.
- lint:md:docs now lints README.md, CONTRIBUTING.md, .github/*.md and
  the Storybook docs. Fix the reported findings and add a
  .markdownlint.json that extends the wp-scripts defaults.

Fixes WordPress#630.
@huzaifaalmesbah

Copy link
Copy Markdown
Member Author

This PR and #632 both edit the scripts block in package.json, so they will conflict. I suggest merging #632 first, since it fixes the original issue (#629). I'll rebase this PR as soon as #632 is merged. "Allow edits by maintainers" is enabled, so feel free to rebase and merge it yourself if that's quicker.

This branch has not been deployed

No deployments
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.

npm scripts lint:pkg-json and lint:md:docs lint nothing

1 participant