Skip to content

Commit

Permalink
Fix: require-atomic-updates false positive across await (fixes #11954) (
Browse files Browse the repository at this point in the history
  • Loading branch information
buhichan committed Dec 18, 2020
1 parent 301d0c0 commit f85b4c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/require-atomic-updates.js
Expand Up @@ -113,6 +113,9 @@ class SegmentInfo {

if (info) {
info.freshReadVariableNames.add(variableName);

// If a variable is freshly read again, then it's no more out-dated.
info.outdatedReadVariableNames.delete(variableName);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/require-atomic-updates.js
Expand Up @@ -150,6 +150,18 @@ ruleTester.run("require-atomic-updates", rule, {
let bar = await get(foo.id);
foo.prop = bar.prop;
}
`,

// https://github.com/eslint/eslint/issues/11954
`
let count = 0
let queue = []
async function A(...args) {
count += 1
await new Promise(resolve=>resolve())
count -= 1
return
}
`
],

Expand Down

0 comments on commit f85b4c7

Please sign in to comment.