Skip to content
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

feat(core): move runtime-lint-utils to eslint plugin #13222

Merged
merged 2 commits into from
Nov 18, 2022

Conversation

meeroslav
Copy link
Contributor

@meeroslav meeroslav commented Nov 17, 2022

Move runtime-lint-utils from workspace to eslint-plugin-nx and nx

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #11937

@meeroslav meeroslav self-assigned this Nov 17, 2022
@nx-cloud-staging
Copy link

nx-cloud-staging bot commented Nov 17, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 8de2449. 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 12 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Nov 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Nov 18, 2022 at 10:35AM (UTC)

@@ -104,6 +104,7 @@ It only uses language primitives and immutable objects
### Utils Type aliases

- [AdditionalSharedConfig](../../devkit/index#additionalsharedconfig)
- [MappedProjectGraph](../../devkit/index#mappedprojectgraph)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not export these publically.

* @param projectGraph
* @returns
*/
export function mapProjectGraphFiles<T>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have some really similar methods. Can we use that instead?

export function createProjectRootMappings(

It's more widely used and I'm pretty sure its fast.

If you'd really like to keep this version, can you put it next to those and leave a comment to figure out which one is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two are doing different things.

  • The createProjectRootMappings creates a map of projectRootPath -> projectName. This can potentially be replaced by mapProjectGraphFiles. I would do that in a separate PR though.
  • The mapProjectGraphFiles adds a fast lookup to graph in the form of filePath -> projectName. Keeping this version is vital for the performance of linter rule.

Moving it to target-project-locator makes sense though.

packages/devkit/index.ts Outdated Show resolved Hide resolved
packages/eslint-plugin-nx/package.json Show resolved Hide resolved
projectGraph.nodes as Record<string, ProjectGraphProjectNode>
).forEach(([name, node]) => {
node.data.files.forEach(({ file }) => {
const fileName = removeExt(file);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a weird way to make a key. Why is it not the dirname?

Copy link
Contributor Author

@meeroslav meeroslav Nov 18, 2022

Choose a reason for hiding this comment

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

Because our imports get resolved to /path/to/folder/file and lookup gets invoked 1000s of times during the lint run.
We need a lookup that's as fast as possible. Any runtime concatenation or extension stripping adds seconds to the total run in the large monorepos.


return {
...projectGraph,
allFiles,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would just return this separately rather than adding it onto the projectGraph

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense but would involve changes in linter rule, so I will move that to a followup PR.

@meeroslav meeroslav marked this pull request as ready for review November 18, 2022 09:52
@meeroslav meeroslav changed the title cleanup(core): move runtime-lint-utils to eslint plugin feat(core): move runtime-lint-utils to eslint plugin Nov 18, 2022
@meeroslav meeroslav merged commit ab6f62a into nrwl:master Nov 18, 2022
@meeroslav meeroslav deleted the move-runtime-utils branch November 21, 2022 13:59
FrozenPandaz added a commit to FrozenPandaz/nx that referenced this pull request Nov 23, 2022
FrozenPandaz added a commit to FrozenPandaz/nx that referenced this pull request Nov 23, 2022
FrozenPandaz added a commit to FrozenPandaz/nx that referenced this pull request Nov 24, 2022
FrozenPandaz added a commit to FrozenPandaz/nx that referenced this pull request Nov 24, 2022
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2023
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.

Reduce unnecessary depdendency burden of eslint-plugin-nx
2 participants