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

Standard on the ternary operator #206

Closed
naknode opened this issue Jul 23, 2015 · 3 comments

Comments

@naknode
Copy link

commented Jul 23, 2015

Take this code for example.

var test = {
  getTest: function (foo) {
    var foo
    var bar = 0
    if (foor == null ? bar = 12 : bar = 5)
  }
}

test.getTest(false)

Using Standard formatting and Standard styling, it will always compile an error whenever there is a ternary operator present.

The error will occur on line 6 at the } character. How would you propose going around this?

Using this for reference:

λ standard --verbose src/js/monsters.js | snazzy
standard: Use JavaScript Standard Style (https://github.com/feross/standard)

\wamp\www\navarra\src\js\monsters.js
  6:4  error  Unexpected token }   undefined

I am a Windows 7 (64-bit) build.

@dcousens

This comment has been minimized.

Copy link
Member

commented Jul 23, 2015

@naknode this isn't just a ternary expression, you are actually missing the followup if block entirely.
Hence, the parsing error error Unexpected token } undefined

@dcousens dcousens added the question label Jul 23, 2015

@naknode

This comment has been minimized.

Copy link
Author

commented Jul 23, 2015

Well, now... don't I feel foolish. I must have mis-read the document wrong on Mozilla. Thank you.

@dcousens

This comment has been minimized.

Copy link
Member

commented Jul 23, 2015

No worries @naknode :)

@dcousens dcousens closed this Jul 23, 2015

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

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