-
Notifications
You must be signed in to change notification settings - Fork 15
Keep tracked files instead of refreshing list of untracked files #61
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
base: main
Are you sure you want to change the base?
Conversation
@@ -19,7 +19,7 @@ const untrackedFilename = "an-untracked-file.js"; | |||
|
|||
const gitMocked: jest.MockedObjectDeep<typeof git> = jest.mocked(git); | |||
gitMocked.getDiffFileList.mockReturnValue([filename]); | |||
gitMocked.getUntrackedFileList.mockReturnValue([untrackedFilename]); | |||
gitMocked.getTrackedFileList.mockReturnValue([filename, "file-with-dirty-index.js"]); |
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.
One of the tests also works with a file called file-with-dirty-index.js
so we have to add it to the "tracked" list too.
@@ -117,11 +110,12 @@ const getProcessors = ( | |||
processorType: ProcessorType | |||
): Required<Linter.Processor> => { | |||
const staged = processorType === "staged"; | |||
const trackedFileSet = new Set(getTrackedFileList()); |
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.
I'm wrapping this in a Set
for faster lookups.
const shouldRefresh = | ||
!diffFileList.includes(filename) && !untrackedFileList.includes(filename); |
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.
This condition not only matches new files but actually all unchanged files, so instead of speeding things up this actually slows the entire lint process.
Yeah noticing this as well, it makes the initial lint take really long to run, even when there is nothing to lint |
#27 introduced a massive performance regression with the recommended
diff/diff
setup. It effectively refreshes the list of untracked files for every unchanged file in the project.Instead of constantly refreshing the tracked file list, it's better to get the list of tracked files once and we can simply check that a file is not in the list.