MCPcopy
hub / github.com/lebab/lebab / enter

Function enter

src/transform/forOf.js:10–30  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

8export default function(ast, logger) {
9 traverser.replace(ast, {
10 enter(node) {
11 const matches = matchAliasedForLoop(node);
12
13 if (matches) {
14 if (indexUsedInBody(matches)) {
15 logger.warn(node, 'Index variable used in for-loop body', 'for-of');
16 return;
17 }
18
19 if (matches.itemKind === 'var' || matches.indexKind === 'var') {
20 logger.warn(node, 'Only for-loops with let/const can be transformed (use let transform first)', 'for-of');
21 return;
22 }
23
24 return withComments(node, createForOf(matches));
25 }
26
27 if (node.type === 'ForStatement') {
28 logger.warn(node, 'Unable to transform for loop', 'for-of');
29 }
30 }
31 });
32}
33

Callers

nothing calls this directly

Calls 4

createForOfFunction · 0.85
warnMethod · 0.80
indexUsedInBodyFunction · 0.70
withCommentsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…