question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require-atomic-updates false positive

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 12.4.0
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using?

Default

Please show your full configuration:

https://github.com/medikoo/eslint-config-medikoo/blob/master/index.js

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const fn = async someObj => {
  let { foo } = someObj;
  await Promise.resolve();
  // Possible race condition: `someObj.bar` might be reassigned based on an outdated value of `someObj.bar`
  someObj.bar = "whatever";
};

What did you expect to happen?

No error reported

What actually happened? Please include the actual, raw output from ESLint.

Error reported:

Possible race condition: `someObj.bar` might be reassigned based on an outdated value of 

Are you willing to submit a pull request to fix this bug?

Not at this point

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:127
  • Comments:57 (11 by maintainers)

github_iconTop GitHub Comments

81reactions
stinovlascommented, Jun 25, 2019

I would say that if nothing else, error message is pretty misleading.

someObj.bar might be reassigned based on an outdated value of someObj.bar

That is simply not true, because someObj.bar = "whatever"; assigns string "whatever" which is not depending on someObj.bar in any way.

Also, it’s not following the rule definition which clearly states that following must be true:

A variable or property is reassigned to a new value which is based on its old value.
46reactions
medikoocommented, Jun 25, 2019

I think this is intentional behavior because that someObj object was read before await expression and written after await expression.

Ok, but that’s pretty aggressive assumption, as in many cases that can be an intentional well-thought construct

In place where it reported for me, it’s totally intentional and there’s no way to write it differently (aside of dropping async/await), due to that I needed to turn off this rule globally.

Still I’d love it to report for me cases as count += await getCount() which are error-prone obviously (and even if not, easy to write in a way they do not report)

Read more comments on GitHub >

github_iconTop Results From Across the Web

await async - race condition error in ESLint require-atomic ...
This looks very much like a false positive. I can't see how the rule conditions apply to your code. If this is your...
Read more >
require-atomic-updates - ESLint - Pluggable JavaScript Linter
This rule has an object option: "allowProperties" : When set to true , the rule does not report assignments to properties. Default is...
Read more >
require-atomic-updates false positive, eslint:recommended, eslint ...
The "extends": "eslint:recommended" property in a configuration file enables rules that report common problems, which have a check mark below. The --fix option ......
Read more >
Bountysource
require -atomic-updates false positive.
Read more >
Migrating to v6.0.0 - ESLint中文文档
To address: Make sure you upgrade to at least Node.js 8 when using ESLint v6. ... might need to disable additional rules to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found