Skip to content

chore: switched repo lint to use nx run-many #6038

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

Merged

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Nov 19, 2022

PR Checklist

Overview

Uses nx run-many as described in #4226.

I tested this locally and verified:

  • Reruns of packages do take from the Nx cache
  • Modifying the contents of a source file invalidates the cache for that package and its dependents

Note that a single uncached run is now ~34% slower in the new system. However, the much more common use case of a user only modifying the eslint-plugin package is ~49% faster:

Lint Type Hyperfine Measurement (old - new) / old x 100%
Original (baseline)1 39.509 s ± 3.353 s (baseline)
New, completely uncached2 53.210 s ± 6.738 s 34% worse
New, uncached eslint-plugin3 20.134 s ± 0.538 s 49% better
New, completely cached4 478.3 ms ± 8.2 ms 98% better

Footnotes

  1. hyperfine "cross-env NODE_OPTIONS=\"--max-old-space-size=16384\" eslint ."

  2. hyperfine "nx run-many --target=lint --all --parallel --skip-nx-cache"

  3. hyperfine "nx run-many --target=lint --all --parallel" --prepare "echo '/* ... */' >> packages/eslint-plugin/src/rules/no-floating-promises.ts || true"

  4. hyperfine "nx run-many --target=lint --all --parallel"

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@nx-cloud
Copy link

nx-cloud bot commented Nov 19, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0afc938. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Nov 19, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 0afc938
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/637b7e125329760009a8ef64
😎 Deploy Preview https://deploy-preview-6038--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review November 19, 2022 05:47
Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

Pending switch over to Nx eslint executor (I'll apply that myself tomorrow)

@JamesHenry JamesHenry dismissed their stale review November 20, 2022 09:42

Updated PR

@@ -34,7 +34,7 @@
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf .rollup.cache && rimraf coverage",
"clean-fixtures": "rimraf -g \"./src/**/fixtures/**/snapshots\"",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "eslint . --ignore-path='../../.eslintignore'",
"lint": "cd ../../ && nx lint @typescript-eslint/ast-spec",
Copy link
Member

@JamesHenry JamesHenry Nov 20, 2022

Choose a reason for hiding this comment

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

I kept these npm script aliases as @bradzacher had previously requested back when I applied this same change to scope-manager.

Personally I run everything from the root or let the Nx Console VSCode extension give me a clickable target trigger in the project.json of the relevant project:

(You can see it here between lines 5 and 6)

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Nifty, thanks. Is there a way around the cd ../.., though? It's kind of annoying to be shoved back into the root directory. Sometimes I do want to have my shell specifically in a package dir.

Copy link
Member

Choose a reason for hiding this comment

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

I think there are still some rough edges with running nx from a nested location, but having said that I tried the example of running:

nx lint @typescript-eslint/ast-spec

Within ./packages/ast-spec and it worked just fine...

It's possible in simple cases like this there are no issues and/or my knowledge is out of date.

I've pushed up an additional commit which removes the cd from all of them 🤞

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nice, thanks! I really like this 😄 very clean.

Copy link
Member Author

Choose a reason for hiding this comment

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

One more feature request I'd have for nx is to be able to switch this to nx lint . in each of them. It'd be nice not to have to redundantly type the package name. Filed nrwl/nx#13289.

@JoshuaKGoldberg JoshuaKGoldberg merged commit e2d1263 into typescript-eslint:main Nov 21, 2022
@JoshuaKGoldberg JoshuaKGoldberg deleted the repo-lint-nx-run-many branch November 21, 2022 13:43
omril1 pushed a commit to omril1/typescript-eslint that referenced this pull request Nov 23, 2022
* chore: switched repo lint to use nx run-many

* chore: replace eslint CLI usage with dedicated Nx executor

* chore: remove unneeded nested .eslintignore files

* chore: npm alias, try without cd to root

Co-authored-by: “JamesHenry” <james@henry.sc>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split up linting internally
3 participants