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: relative cache support #114

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

cs6cs6
Copy link

@cs6cs6 cs6cs6 commented Oct 5, 2023

…velopers or into ci machines.

Summary

Related Issues

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 5, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@eslint-github-bot
Copy link

Hi @cs6cs6!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@cs6cs6 cs6cs6 changed the title This feature is to create an eslintcache that can be shared across de… feat: relative cache support Oct 5, 2023
@cs6cs6
Copy link
Author

cs6cs6 commented Oct 9, 2023

Hello. How do I draw attention to this PR? I believe I am only awaiting feedback.

@nzakas nzakas added the Initial Commenting This RFC is in the initial feedback stage label Oct 10, 2023
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together and sorry for the delay -- we are a small team and have a lot to do.

Overall I think this looks good. I left some feedback throughout.

designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

This is looking good. Left comments throughout on areas we can clarify and clean up.

designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved

I originally planned the shareable-cache flag so that users of eslint could not be surprised by changed cache behavior, and would also not have to regenerate their cache
for a patch version change. But I discovered by testing that there is no way to NOT force people to regenerate their eslint cache with this change. That's because by adding
the 'shareable-cache' flag, it adds a property to the ConfigArray object. Even if it's set to false (the old behavior), the object's structure changes with a new property
Copy link
Member

Choose a reason for hiding this comment

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

How is this changing the ConfigArray? This setting is at the CLI level, not at the config level, so there shouldn't be any changes to the ConfigArray.

Copy link
Author

Choose a reason for hiding this comment

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

The object itself, along with all of its properties (set or not) is rolled into the computed hash code that goes into the file. So, simply by adding a new property, the hash computed of the object changes, even if that property is deliberately set to create no change in behavior.

designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
designs/2023-relative-cache/README.md Outdated Show resolved Hide resolved
cs6cs6 and others added 4 commits October 25, 2023 12:28
Accepting code review suggestion where backticks are added for readability.

Co-authored-by: Nicholas C. Zakas <[email protected]>
Per code review, adding backticks for readability.

Co-authored-by: Nicholas C. Zakas <[email protected]>
- `lib/cli.js`: Add the `shareableCache` option, defaulted to false, in the `translateOptions `function.

### Changing cache file serialization
- `lib/cli-engine/lint-result-cache.js`: Add the properties `cwd` and `shareableCache` to the `LintResultCache` class. `cwd` is a string, the current working directory. `shareableCache` is a boolean, the result of the user's passed in command line parameter. Use these values in two main places:
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 we should clarify what we mean by the current working directory that will be passed to the LintResultCache class. Is it process.cwd(), or cwd that was passed to ESLint/FlatESLint constructor? In the latter case, is there a way to pass cwd to file-entry-cache or we could end up calculating paths differently?

Copy link
Member

Choose a reason for hiding this comment

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

Another question is does file-entry-cache support relative paths? All tests seem to be with absolute paths:

https://github.com/jaredwray/file-entry-cache/blob/master/test/specs/cache.js

Copy link
Author

Choose a reason for hiding this comment

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

It will. I am just going to push up the code review sometime today. I have a complete and working branch on this task, and most of your questions wuold be resolved by the code review/better answered looking at the code changes.

Copy link
Member

Choose a reason for hiding this comment

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

Don't forget to answer the question regarding what cwd is from the previous comment.

Copy link
Author

Choose a reason for hiding this comment

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

Is it process.cwd(), or cwd that was passed to ESLint/FlatESLint constructor?

When created in cli-engine.js, it's options.cwd. It is also referred to as 'cwd' in the code.
When created in flat-eslint.js, it's processedOptions.cwd.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I have updated the code, and the flat-eslint.js file no longer exists in my code branch. I see a lot of the code duplication around parameter parsing has been removed. I am updating my RFC accordingly.

In ESLint 9, eslint.js has been renamed to legacy-eslint.js and flat-eslint.js is now named eslint.js.

Copy link
Member

Choose a reason for hiding this comment

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

@jaredwray are you still interested in submitting a pull request? Just let us know if you need any help.

Choose a reason for hiding this comment

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

@fasttime - I made the changes to support the relative path and wanted to confirm that is the change you need to make it work with file-entry-cache.

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@fasttime - jaredwray/file-entry-cache#46

Thanks! Now it would be great if someone could draft a PR in ESLint to test these changes.

@nzakas
Copy link
Member

nzakas commented Dec 8, 2023

@cs6cs6 there were still some outstanding requests for you to consider here. Are you still working on this?

@nzakas
Copy link
Member

nzakas commented Jan 9, 2024

@cs6cs6 just checking back to see if you intend on finishing this up?

@cs6cs6
Copy link
Author

cs6cs6 commented Jan 12, 2024

Hello, I apologize for the delay. I am working on this today.

@nzakas
Copy link
Member

nzakas commented Jan 17, 2024

@bmish @mdjermanovic can you take another look at this?

@cs6cs6
Copy link
Author

cs6cs6 commented Jan 31, 2024

Hello. I am happy to answer further questions or clarify things. My team solved our critical build speed issue by removing a lot of our more costly linter rules, and running prettier outside of eslint instead of inside. But I would still like to be able to commit this change if you are interested. If you are not interested in this change, please let me know.

@nzakas
Copy link
Member

nzakas commented Feb 5, 2024

Ping @bmish @mdjermanovic

@mdjermanovic
Copy link
Member

I left a new comment on this conversation: #114 (comment)

@Rec0iL99
Copy link
Member

Hey @jaredwray, could you please reformat your last #114 (comment).

@jaredwray
Copy link

Hey @jaredwray, could you please reformat your last #114 (comment).

Yep. Did above. Going to get tests around this over the next 72 hours and respond here on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Initial Commenting This RFC is in the initial feedback stage
Projects
None yet
7 participants