Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: require-atomic-updates false positive across await (fixes #11954) #13915

Merged
merged 1 commit into from Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
buhichan marked this conversation as resolved.
Show resolved Hide resolved
}
`
],

Expand Down