Skip to content

Commit 62a99b7

Browse files
committed
refactor(@angular-devkit/schematics): avoid for await...of with promise arrays
The upcoming version of typescript Eslint rules will fail the `await-thenable` rule for cases of for await...of that use promise arrays. This change removes the usage to avoid lint failures during the version update. Ref: https://typescript-eslint.io/rules/await-thenable/#async-iteration-for-awaitof-loops
1 parent 909cfac commit 62a99b7

File tree

1 file changed

+8
-2
lines changed
  • packages/angular_devkit/schematics/src/rules

1 file changed

+8
-2
lines changed

packages/angular_devkit/schematics/src/rules/base.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ export function empty(): Source {
3535
export function chain(rules: Iterable<Rule> | AsyncIterable<Rule>): Rule {
3636
return async (initialTree, context) => {
3737
let intermediateTree: Observable<Tree> | undefined;
38-
for await (const rule of rules) {
39-
intermediateTree = callRule(rule, intermediateTree ?? initialTree, context);
38+
if (Symbol.asyncIterator in rules) {
39+
for await (const rule of rules) {
40+
intermediateTree = callRule(rule, intermediateTree ?? initialTree, context);
41+
}
42+
} else {
43+
for (const rule of rules) {
44+
intermediateTree = callRule(rule, intermediateTree ?? initialTree, context);
45+
}
4046
}
4147

4248
return () => intermediateTree;

0 commit comments

Comments
 (0)