Skip to content

Conversation

@Planeshifter
Copy link
Member

@Planeshifter Planeshifter commented Jan 3, 2026

Resolves stdlib-js/metr-issue-tracker#62.

Description

What is the purpose of this pull request?

This pull request:

  • separates the package.json metadata validation from the package.json linting
  • adds a new make recipe for validating all package.json files that might need to have their metadata updated for a list of files
  • adds package.json metadata validation to pre-commit hook

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".


@stdlib-js/reviewers

@Planeshifter
Copy link
Member Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added bot: In Progress Pull request is currently awaiting automation. and removed bot: In Progress Pull request is currently awaiting automation. labels Jan 3, 2026
@stdlib-js stdlib-js deleted a comment from stdlib-bot Jan 3, 2026
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@Planeshifter Planeshifter force-pushed the philipp/move-pkg-json-validation-to-make branch from c3c09bb to f02bd2a Compare January 3, 2026 19:28
@Planeshifter
Copy link
Member Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 3, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 3, 2026
# Check if metadata fields need to be updated in package.json files of affected packages:
dirs=$(echo "${files_to_process}" | tr ' ' '\n' | \
xargs dirname | \
sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/[^@]*)?$//' | \
Copy link
Member Author

@Planeshifter Planeshifter Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Replaced (\/.*)? with (\/[^@]*)? to avoid converting paths like ./lib/node_modules/@stdlib/utils/lib to ./, which is undesired (we would want ./lib/node_modules/@stdlib/utils directory in this example). By forbidding @, we can ensure that only lib folders after /@stdlib/ will be stripped.

@Planeshifter Planeshifter marked this pull request as ready for review January 3, 2026 19:32
@Planeshifter Planeshifter requested a review from kgryte January 3, 2026 19:33
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 3, 2026
@kgryte kgryte added Tools Issue or pull request related to project tooling. and removed Needs Review A pull request which needs code review. labels Jan 5, 2026
# @example
# make validate-pkg-json FILES='/foo/lib/index.js /bar/package.json'
#/
validate-pkg-json: $(NODE_MODULES)
Copy link
Member

@kgryte kgryte Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This recipe is somewhat oddly named for a few reasons.

  1. I am not sure we have a validate-* command anywhere else among the make recipes.
  2. The target doesn't follow the convention of appending -files when a recipe is intended to work with a list of files (e.g., lint-javascript-files).

Instead, I would name this target lint-pkg-json-metadata-files.

A few other comments:

  1. In contrast to other linters (e.g., ESLint), this doesn't support the FAST_FAIL environment variable. To do so, we would do something similar to our ESLint recipes where we'd individually iterate over each file.
  2. I think we should have a corresponding lint-pkg-json-metadata recipe which supports globs. Granted, lint-package-json above doesn't work like that atm. This can be punted to a future PR.
  3. I mention (2) because it is odd to me that we need two separate lint commands to fully lint a single package.json file. Because one recipe works on FILES and the other doesn't, we cannot readily create a single lint-pkg-json command which delegates to two more specialized recipes.

Longer term, I think we would be best served by the following targets:

  • lint-pkg-json-schema
  • lint-pkg-json-schema-files
  • lint-pkg-json-metadata
  • lint-pkg-json-metadata-files
  • lint-pkg-json
  • lint-pkg-json-files

where lint-pkg-json then has lint-pkg-json-schema and lint-pkg-json-metadata as prerequisites.

For this PR, I suggest going ahead and at least creating a beachhead by renaming the target and updating the various other downstream consumers in this PR accordingly. I'd also suggest refactoring the recipe to support FAST_FAIL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While its true that this is named somewhat differently and lacking the -files suffix that other targets have, my rationale was that it is indeed quite different, because we are not actually linting a list of files. Instead, we resolve all package.json files associated with a list of files and then check whether they need to be updated. Your comment doesn't wrestle with this crucial distinction at all, I think?
FAST_FAIL also doesn't make sense given this context

Copy link
Member

@kgryte kgryte Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. This is package-level linting (e.g., if a C implementation is added to a package, then we need to confirm that the package.json is updated accordingly).

In which case, this may be better placed in make/lib/lint/pkgs. Locally, I have a WIP recipe for doing whole package linting with the target make lint-pkgs. Let me go ahead and commit that recipe.

Then, I suggest we rename to lint-pkgs-metadata-files and move the recipe to lint/pkgs. That work for you?

And yes, you're right that FAST_FAIL doesn't map well here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the draft recipe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that works. Will update PR accordingly.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Jan 5, 2026
@kgryte
Copy link
Member

kgryte commented Jan 5, 2026

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 5, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 5, 2026
@kgryte
Copy link
Member

kgryte commented Jan 6, 2026

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 6, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Tools Issue or pull request related to project tooling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Move the ⁠package.json file CI lint check into a ⁠make recipe and add to pre-commit hook

4 participants