Skip to content

lintFiles() to await on ESLint.outputFixes()#318

Merged
theoludwig merged 1 commit intomasterfrom
unknown repository
Jan 15, 2023
Merged

lintFiles() to await on ESLint.outputFixes()#318
theoludwig merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jan 15, 2023

This ensures that fixes are written before resolving.

Without this, the file may be in a weird state if consumed right after calling lintFiles() (e.g. reading the files right after calling lintFiles() would return an empty string, stat would show a zero-sized file).

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[x] Bug fix
[ ] New feature
[ ] Other, please explain:

What changes did you make? (Give an overview)

Added await to this.eslint.ESLint.outputFixes(result) to ensure the fixed files are written before lintFiles() returns.

Under the hood, ESLint.outputFixes() is an async function that awaits on a promisified fs.writeFile().

Which issue (if any) does this pull request address?

None.

Is there anything you'd like reviewers to focus on?

Cross-platform testing. Issue may be OS-dependent because it deals with the filesystem. This issue happened on a Windows machine, I cannot verify on other platforms.

This ensures that fixes are written before resolving.

Without this, the file may be in a weird state if consumed right
after calling lintFiles() (e.g. reading the files right after
calling lintFiles() would return an empty string, stat would show a
zero-sized file).
@welcome
Copy link
Copy Markdown

welcome bot commented Jan 15, 2023

🙌 Thanks for opening this pull request! You're awesome.

Copy link
Copy Markdown
Contributor

@theoludwig theoludwig left a comment

Choose a reason for hiding this comment

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

Thanks!

Indeed if outputFixes is an async function we should await it.

@theoludwig theoludwig merged commit 12c96e5 into standard:master Jan 15, 2023
@welcome
Copy link
Copy Markdown

welcome bot commented Jan 15, 2023

🎉 Congrats on getting your first pull request landed!

@voxpelli
Copy link
Copy Markdown
Member

Released in 15.1.0, thanks 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants