-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Rationale Resolves #151. This makes it so a promise must be awaited (or otherwise handled, just not ignored) in Angular tests, making them match other code. Resolves #115. This makes it so a function marked `async` must `await` something, not contain only synchronous code and not return a promise. # Implementation 1. Stop disabling `no-floating-promises` in Angular tests. See PR comment for rationale for keeping `no-unbound-method: 'off'` here. - this repo even had some Angular tests that violated this rule because they were using stale `jasminewd2` types. I fixed those by using `jasmine` types instead (and fixing a playwright test that was incorrectly referencing jasmine types) - this required adding an `.npmrc` since my dev machine is configured to use Artifactory 3. Set `no-return-await: 'off'` in the JS ruleset. This [rule is now deprecated by ESLint](https://eslint.org/docs/latest/rules/no-return-await) because returning an awaited promise is no longer a performance concern. - the related `@typescript-eslint/return-await': 'error'` was already enabled and is still useful because [it enforces the inverse](https://typescript-eslint.io/rules/return-await/), that you should await promises rather than just return them because you get better stack traces 4. Set `'require-await': 'error'` in the JS ruleset and `'@typescript-eslint/require-await': 'error'` in the TS-with-typechecking ruleset. 5. Change files for beachball marked `minor` in accordance with CONTRIBUTING.md guidance for rule changes and include package-specific descriptions of the changes # Testing [A draft PR](https://dev.azure.com/ni/DevCentral/_git/Skyline/pullrequest/761645) into `systemlink-lib-angular` shows the impact of some of these changes. It requires mostly mechanical changes and catches lots of legitimate issues. I also updated a couple test files in this repo to include more async cases and played around with those implementations locally to verify the rules were working. --------- Co-authored-by: Milan Raj <[email protected]>
- Loading branch information
Showing
13 changed files
with
52 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ node_modules | |
.DS_Store | ||
*.tgz | ||
.vscode | ||
.npmrc | ||
./rules.txt | ||
./rules-diff.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org/ |
7 changes: 7 additions & 0 deletions
7
change/@ni-eslint-config-angular-225ce3da-b49d-4df7-ace0-b99abb8fbcb0.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Rule changes for asynchronous code:\\n 1. Functions marked `async` must now include an `await`. The rule `'@typescript-eslint/require-await'` changed from `'off'` to `'error'`.\\n 2. Test code must now correctly handle promises. The rule `'@typescript-eslint/no-floating-promises'` changed from `'off'` to `'error'`.", | ||
"packageName": "@ni/eslint-config-angular", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@ni-eslint-config-javascript-4569f2fb-83ed-4863-9f95-96f907ede343.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Rule changes for asynchronous code:\\n 1. Functions marked `async` must now include an `await`. The rule `'require-await'` changed from `'off'` to `'error'`.\\n 2. It is now acceptable for a function to return an awaited promise. The rule `'no-return-await'` changed from `'error'` to `'off'`.", | ||
"packageName": "@ni/eslint-config-javascript", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@ni-eslint-config-typescript-32797652-8b30-47bc-b259-dfe598d5a4e3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Rule changes for asynchronous code:\\n 1. Functions marked `async` must now include an `await`. The rule `'@typescript-eslint/require-await'` changed from `'off'` to `'error'`.", | ||
"packageName": "@ni/eslint-config-typescript", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters