Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Async-ified Linter.lint #3336

Closed
wants to merge 6 commits into from
Closed

Async-ified Linter.lint #3336

wants to merge 6 commits into from

Conversation

JoshuaKGoldberg
Copy link
Contributor

PR checklist

Overview of change:

Changed Linter.lint to be async and read/write files using the asynchronous fs APIs. Necessitated also changing applyAllFixes and applyFixes within Linter, runTests and runTest within tests, and the runner logic in ruleTestRunner.

CHANGELOG.md entry:

[api] Breaking change: Linter.lint is now async (returns a Promise)

const files: string[] = [];
for (let pattern of patterns) {
if (path.basename(pattern) !== "tslint.json") {
pattern = path.join(pattern, "tslint.json");
}
files.push(...glob.sync(pattern));
}
return files.map((directory: string): TestResult => runTest(path.dirname(directory), rulesDirectory));
return await Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't return await promises, just return the Promise. There are several cases thoughout this PR.

There's already a PR to add a rule to prevent this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting! I remember anecdotally hearing some preference for return await for standardization of where execution context results during errors... but all I can find now to back it up is https://stackoverflow.com/questions/38708550/difference-between-return-await-promise-and-return-promise (and that doesn't). Will change.

@ajafff
Copy link
Contributor

ajafff commented Oct 17, 2017

Currently I'm -0 on this one.
I'm not really convinced ot the benefits of the change.
And I see some compatibilty problems for API users that need a sync result.

But let's continue this discussion in the issue you just created.

@JoshuaKGoldberg JoshuaKGoldberg deleted the async-apply-fixes branch October 23, 2017 05:46
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.

2 participants