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

Weird behavior with await #268

Closed
julien-f opened this issue Sep 21, 2015 · 5 comments

Comments

@julien-f
Copy link

commented Sep 21, 2015

(async function () {
  // Missing space before keyword "await".
  !await true

  // Unexpected space after unary operator "!".
  ! await true

  // Works.
  !(await true)
})()
@feross

This comment has been minimized.

Copy link
Member

commented Sep 21, 2015

This is caused by two rules that make sense alone but conflict in this situation, and other situations like it.

I opened as an issue on eslint to get their feedback: eslint/eslint#3878

@julien-f

This comment has been minimized.

Copy link
Author

commented Sep 23, 2015

It does not work either with string interpolation:

(async function () {
  console.log(`${await 'foo'}`)
})()

So your proposal to disable this rule for unary operators does not really make sense.

await is very different from other keywords (if, return, etc.) as it is part of an expression and IMHO it should be treated differently, and the same goes for yield.

@LinusU

This comment has been minimized.

Copy link
Member

commented Oct 26, 2015

I found another strange behaviour which I think is the same as this:

const [bread, butter] = [await breadPromise, await butterPromise]

Missing space before keyword "await".

As you can see I don't use initial spaces in arrays ([a, b] vs. [ a, b ]) which standard is totally fine with, so it seems weird that I need to do it when using await.

@matjaz

This comment has been minimized.

Copy link

commented Jan 26, 2016

any updates on this?

@feross

This comment has been minimized.

Copy link
Member

commented Feb 4, 2016

This issue is similar to #387. I'll repeat what I posted there earlier:

This issue is caused by the keyword spacing rules that we have enabled conflicting with other spacing rules that we have enabled.

Fortunately, the next version of eslint (v2) (which will ship in standard v6) has a new, better rule keyword-spacing which doesn't check conditions which are handled by other rules.

From the docs for keyword-spacing:

This rule is designed carefully to not conflict with other spacing rules. Basically this rule ignores usage of spacing at places that other rules are catching. So the following patterns are considered not problems.

This is fixed on the v6 branch and will be released as standard v6 soon.

@feross feross closed this Feb 4, 2016

@feross feross added bug and removed blocked question labels Feb 4, 2016

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.