Skip to content

A package-lock.json for eslint? #142902

Closed

Description

@workingjubilee

Recently there was a proposal to run npx eslint without first npm installing it.

However, I personally have no idea how dependencies would have been resolved for doing this. Normally, for code in the repository, we have a Cargo.lock that decides what will be resolved and we deliberately bump it when we want to update. This provides some assurance, at least, that we don't resolve random packages.

Part of my confusion with that PR was... that. If we're going to run JS testing and linting, then it's unclear to me why we don't also have locks so that we know what code we are running.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 23, 2025
  2. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    A-tidyArea: The tidy tool
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 23, 2025
  3. jieyouxu commented on Jun 23, 2025

    @jieyouxu
    Member

    I believe this was answered by @yotamofek in a review comment chain here

    It will always resolve to that exact version specified, there's no implicit semver operator here like cargo does :)

  4. added
    C-discussionCategory: Discussion or questions that doesn't represent real issues.
    and removed
    C-bugCategory: This is a bug.
    on Jun 23, 2025
  5. yotamofek commented on Jun 23, 2025

    @yotamofek
    Contributor

    I believe this was answered by @yotamofek in a review comment chain here

    It will always resolve to that exact version specified, there's no implicit semver operator here like cargo does :)

    I think it's a partial answer to a slightly different question.

    Recently there was a proposal to run npx eslint without first npm installing it.

    That's what npx does - it runs packages without having to explicitly install them first. That PR you are referring to (#142851), in its original version, wouldn't have changed anything re: version resolution etc.

    Part of my confusion with that PR was... that. If we're going to run JS testing and linting, then it's unclear to me why we don't also have locks so that we know what code we are running.

    That's a good point. npx or npm install aside, even if we pick specific eslint version (and we do since the implicit semver operator in the npm world is =, as opposed to cargo which implicitly turns something like 0.x.y into >=0.x.y, <0.x+1), there are two additional guarantees a package-lock.json would give us:

    1. a digest of the specific eslint version, which can guard against certain cases of MitM, I guess?
    2. specific resolution of eslint's recursive dependencies - even if npx or npm install chooses a specific eslint version, that doesn't mean some deeply nested dependency can't resolve to a newer version, in accordance with the semver range specified for it, which opens us up to the good ol' supply-chain attack

    So yeah, I think a package-lock.json (plus --freeze) for anything run by tidy would not hurt.

  6. Noratrieb commented on Jun 23, 2025

    @Noratrieb
    Member

    Yeah, we should have a package-lock to lock the dependencies of eslint. I've had many bad experiences before at work work eslint and things breaking :).

  7. added
    C-bugCategory: This is a bug.
    and removed
    C-discussionCategory: Discussion or questions that doesn't represent real issues.
    on Jun 23, 2025
  8. yotamofek commented on Jun 23, 2025

    @yotamofek
    Contributor

    Cool, I can do that (along with making eslint run only if changes were detected in JS files)
    @rustbot claim

  9. 2 remaining items

  10. GuillaumeGomez commented on Jun 27, 2025

    @GuillaumeGomez
    Member

    Yeah, we should have a package-lock to lock the dependencies of eslint. I've had many bad experiences before at work work eslint and things breaking :).

    Important to be noted: since we install JS dependencies in docker builds, the package-lock.json file would need to live in src/ci/docker, which is pretty bad. Hence why currently, we track version in a file in this folder which is retrieved by bootstrap and then check that's the current version installed.

    I don't think putting the package-lock.json (or package.json) file there would make sense, hence why I didn't do it. I'd love to make things simpler for everyone but currently it seems to not be possible or to be very ugly.

  11. Kobzol commented on Jun 27, 2025

    @Kobzol
    Member

    To clarify, we can keep the lockfile outside of src/ci/docker, as long as we install the JS packages at (Docker image) runtime, rather than at (Docker image) build time.

  12. workingjubilee commented on Jun 28, 2025

    @workingjubilee
    MemberAuthor

    I don't think putting the package-lock.json (or package.json) file there would make sense, hence why I didn't do it. I'd love to make things simpler for everyone but currently it seems to not be possible or to be very ugly.

    I do love beautiful solutions.

    But I think "ugly but works", when the matter is at most an extra few files of no significant size, is better than "reinventing the incredible complexities of dependency management in an ad hoc manner, strewn across completely unrelated parts of the codebase".

  13. GuillaumeGomez commented on Jun 28, 2025

    @GuillaumeGomez
    Member

    @lolbinarycat I reassigned @yotamofek as they are still working on it as far I know and even have an open PR.

  14. GuillaumeGomez commented on Jun 28, 2025

    @GuillaumeGomez
    Member

    But I think "ugly but works", when the matter is at most an extra few files of no significant size, is better than "reinventing the incredible complexities of dependency management in an ad hoc manner, strewn across completely unrelated parts of the codebase".

    Agreed, hence why I suggested to only run JS checks if a JS file was modified.

  15. yotamofek commented on Jun 28, 2025

    @yotamofek
    Contributor

    @lolbinarycat I reassigned @yotamofek as they are still working on it as far I know and even have an open PR.

    I was gonna work on it after @lolbinarycat finished #142924 , but she hit me up on Zulip and said she was gonna work on this and integrate it into her PR, so I told her to assign this issue to herself. :)
    Haven't started working on this yet, and definitely don't have a PR, so had no problem with her taking over.

  16. GuillaumeGomez commented on Jun 28, 2025

    @GuillaumeGomez
    Member

    Ah my bad, then reassigning @lolbinarycat (please write a message so people not involved in conversation understand what's going on 😆 ).

  17. lolbinarycat commented on Jun 29, 2025

    @lolbinarycat
    Contributor

    Yeah I don't think it makes sense to land #142924 without adding lockfiles first, and trying to do this work in parallel would cause conflicts, so I'm just going to try to it all in one PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-tidyArea: The tidy toolC-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions