-
Notifications
You must be signed in to change notification settings - Fork 13.5k
tidy: only run eslint on JS files if specified with "--extra-checks" #142851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tidy: only run eslint on JS files if specified with "--extra-checks" #142851
Conversation
99d4420
to
986b270
Compare
Seems good to me, thanks! r=me once CI pass. @bors delegate+ |
✌️ @yotamofek, you can now approve this pull request! If @GuillaumeGomez told you to " |
@bors r=@GuillaumeGomez rollup |
...I am not modifying the JS files in this repository. |
I am going to uninstall Node.js from my machines, I guess. |
tidy
users to run npm install eslint
npx install eslint
instead of npm
@bors r- How much extra time does this add for the tidy execution for folks who do have npx? We've had numerous attempts to optimize this flow, and I think the majority of contributors aren't editing JavaScript so this is just wasted time for them. Maybe we can make this an opt-in in bootstrap.toml or perhaps detect changed files or similar? |
npx install eslint
instead of npm
npx eslint
instead of npm install
Yeah, sorry, didn't phrase that correctly at all. I meant that not having Your modified title isn't quite right, this PR doesn't change the way |
This PR actually seems to make But yeah, making the |
Oh, well, yes, but the step that is
The original title just seemed slightly vague. Feel free to modify the PR title further or even revert it to your original if you disagree, I won't touch it again. |
Hi, can we please gate the eslint stuff behind You can see e.g. rust/src/tools/tidy/src/ext_tool_checks.rs Lines 62 to 66 in d4e1159
--extra-checks flag.
Invocation wise, I would expect it be sth like In one of the CI |
Doing this as part of Footnotes
|
Also hold on, will this try to use any eslint version, and not a pinned version? |
src/tools/tidy/src/rustdoc_js.rs
Outdated
let mut child = match Command::new("npx") | ||
.arg("eslint") | ||
.arg(format!("eslint@{eslint_version}")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jieyouxu It should always try to use this version but I am not sure what the dependency resolution process for npx is from here, e.g. if it will use a compatible version that isn't the specified one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right... yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will always resolve to that exact version specified, there's no implicit semver operator here like cargo does :)
986b270
to
7a01b2a
Compare
7a01b2a
to
2bd8d2e
Compare
npx eslint
instead of npm install
@jieyouxu mind taking a look please? |
Also, stop pre-installing `eslint` - the docker image is not cached in CI, so there's no point in explicitly `npm install`ing it instead of just letting `npx` download it
Please don't. I don't want to gate eslint checks behind an option, too easy to miss. |
I agree it's easy to miss, but I also agree with what other people were saying about it being a bit of a time sink (though pretty minimal) for the vast majority of people who aren't working on the rustdoc frontend. Anyways, these are the options I see:
Whatever is decided, I'm happy to make the needed modifications, but seems to me like there needs to be some consensus first? |
I don't feel strongly enough to block running this in the default flow (I guess I could just uninstall
Otherwise, you bear the linting cost for having node installed even if you don't work on the js files... |
Then let's keep it as it is currently? If |
Sounds good. |
Adding comments and even a link to this PR would be a very good idea! |
…t-installation-req, r=GuillaumeGomez Document why tidy checks if `eslint` is installed via `npm` Discussion here: rust-lang#142851
I agree with @jieyouxu, detecting the version is not a good approach. It is not intuitive, to disable the check, you have to uninstall eslint, which you might want to have for other reasons, and if you have a different version, it fails tidy. The Python linting in tidy instead manages a virtualenv for you and installs the right version of packages, which is what we should do. Also, if you get a linting error once on CI, and then you install the correct eslint version locally, you'll then get worse tidy performance going forward. We already have strong precedent for gating Python/C++ checks behind an optional flag. I don't see why we should do an exception for JS, it's in a similar category. For people who work on JS often, you can just invoke tidy with the extra check or write a bash script that will do it for you. With the opt-in, tidy can actually error out when eslint is missing on CI, which it currently doesn't; if eslint disappears from the CI image, we will silently stop running the linter now, which is not great. We will also stop checking the installed version of eslint, which is a hack anyway, and it makes running tidy slower. |
Interesting point: you have the opposite approach but it also makes sense. My worry is that if we need to add an extra argument to |
I agree that running it if we detected changed JS files is the ideal option: for non-JS-contributors it will minimize Question is, is the "changed file detection" mechanism trustworthy? |
Well, kinda. We already use this mechanism in stuff like #142677 |
The 5k message was mostly a UX failure. The detection should be fairly robust now. If the check for modified files is fast, I wouldn't mind it. Although it is not 100% to just check if |
Pretty sure I wrote that warning! The issue was if Anyways, I'm gonna take a crack at this, as well as adding UPDATE: fairly sure none of the warnings show unless you run with UPDATE: also wanna throw es-check in there too |
We actually completely removed the remote handling, because it was unreliable and requires CI hacks. Now we just find the most recent commit authored by bors, that seems to be much more robust. |
just got |
To clarify, I think that the remote handling was used both for detecting download-ci-XXX commits and also the rustfmt check. The download-ci checking is now working well, but I don't remember how exactly the rustfmt check works. |
Here's my attempt: #142924 |
npx
already obviates the need to have the package installed locally, we can just asknpx
to run the pre-configured version ofeslint
This should reduce some friction for
rustdoc
contributors who are usingtidy
.The one downside I can think of is that this will make skipping the
eslint
check more difficult to do, but not sure there's a good use-case for that.r? @GuillaumeGomez since you added the
eslint
check totidy
:)