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] has too many false positives #12423

Closed
fabiospampinato opened this issue Oct 13, 2019 · 3 comments
Closed

[require-atomic-updates] has too many false positives #12423

fabiospampinato opened this issue Oct 13, 2019 · 3 comments
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

@fabiospampinato
Copy link

fabiospampinato commented Oct 13, 2019

Tell us about your environment

  • ESLint Version: 6.5.1
  • Node Version: 10.15.0
  • npm Version: 6.4.1

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

@typescript-eslint/parser

Please show your full configuration:

Here it is, just uncomment the "require-atomic-updates" rule.

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

async fn ( note ) {
	let stat;
	if ( !stat ) stat = await File.stat ( note.filePath );
	note.metadata.created = stat ? stat.birthtime : new Date ();
}
npx eslint src --ext '.ts, .tsx'

What did you expect to happen?

No error detected.

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

ESLint doesn't like my assignment, according to the rules of this rule:

A variable or property is reassigned to a new value which is based on its old value

I don't think this is the case, the new value doesn't depend on the previous value.

A yield or await expression interrupts the assignment after the old value is read, and before the new value is set.

Kind of, but stat is a locally scoped variable and by using await I'm pausing the entire function so nothing else could mutate the value assigned to stat while I'm awaiting.

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

I'm not too familiar with the AST, but with some pointers perhaps I can help.

@fabiospampinato fabiospampinato added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Oct 13, 2019
@Mossop
Copy link

Mossop commented Oct 14, 2019

I'm seeing similar issues, maybe this is an issue with the TypeScript parser?

I get the error flagged just assigning an enum: https://github.com/FractalBrew/media-metadata/blob/master/src/ifd.ts#L244

@JakeRowsell89
Copy link

It may be related to await as opposed to TypeScript, could it be a duplicate of this: #11954

@platinumazure
Copy link
Member

I'm going to go ahead and close this as a duplicate of #11899. Please follow that issue for updates. Thanks!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 13, 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 Apr 13, 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

4 participants