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

require-atomic-updates isn't consistent between locals and params #11911

Closed
darthwalsh opened this issue Jun 27, 2019 · 1 comment
Closed

require-atomic-updates isn't consistent between locals and params #11911

darthwalsh opened this issue Jun 27, 2019 · 1 comment
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon

Comments

@darthwalsh
Copy link

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 10.15.3
  • npm Version: 6.4.1

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

Please show your full configuration:
require-atomic-updates: error

Configuration
env:
  browser: true
  es6: true
globals:
  Atomics: readonly
  SharedArrayBuffer: readonly
parserOptions:
  ecmaVersion: 2018
rules:
  require-atomic-updates: error

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

Demo online

safe = async p => {
  const player = p
  player.money += await player.calculateIncome(); // no error
}

unsafe = async player => {
  player.money += await player.calculateIncome(); // Possible race condition
}
node_modules/.bin/eslint a.js

What did you expect to happen?
I'd prefer neither line to cause an error, but for consistency both lines should at least have the same behavior.

#10655 specified that local variables should be excluded. Function parameters have the same scope as local variables in the function. As far as I can reason as long as the local or param isn't captured by a closure, there's no reason to treat them differently.

If this was changed, I suspect it would also fix #11899

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

~/code/blah$ node_modules/.bin/eslint a.js

~/code/blah/a.js
  7:3  error  Possible race condition: `player.money` might be reassigned based on an outdated value of `player.money`  require-atomic-updates

✖ 1 problem (1 error, 0 warnings)

Are you willing to submit a pull request to fix this bug?
My employer hasn't pre-approved your CLA, and there's probably no business justification for fixing this

@darthwalsh darthwalsh added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jun 27, 2019
darthwalsh added a commit to darthwalsh/Austerity that referenced this issue Jul 3, 2019
darthwalsh pushed a commit to darthwalsh/Austerity that referenced this issue Jul 4, 2019
* Update dependency eslint to v6

* Disable require-atomic-updates to allow eslint upgrade

Rules require-atomic-updates isn't useful
eslint/eslint#11911
@mysticatea
Copy link
Member

Thank you for your report.

I think this is a duplicate of #11899. Please track that issue.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 6, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

2 participants