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

Semicolons issue #525

Closed
taoeffect opened this issue May 19, 2016 · 1 comment

Comments

@taoeffect
Copy link

commented May 19, 2016

I've some code:

it('Should create user George', async function () {
  (await n.goto(page('new-user')))
  .should.containEql({code: 200, url: page('new-user')})
  // for some reason we have to access `this`
  // only *after* we call `await` once.
  this.timeout(12000)
  console.log(`<--${new Date().toTimeString()}-->`)
  console.log('typeof this:', typeof this, Object.keys(this))
  await n.wait(2000)
  console.log(`</-${new Date().toTimeString()}-->`)
  return n.wait('#response')
  .insert('input[name="name"]', 'George')
  .insert('input[name="email"]', 'george@lasvegas.com')
  .insert('input[name="password"]', '$$111$$')
  .click('form.new-user button.sign-in')
  .wait(() => document.querySelector('#response').innerText !== '')
  .evaluate(() => document.querySelector('#response').className)
  .should.finally.not.equal('error')
})

This results in an error if the this.timeout(12000) is the first line in the test because of an "ASI" (automatic semicolon insertion) issue.

Oddly enough, moving it up to the first line and putting a semicolon there as shown below works and passes the linter:

    it('Should create user George', async function () {
      // this semi-colon at the end of of this.timeout is *required*.
      // For details, see: https://phabricator.babeljs.io/T7372#78495
      this.timeout(12000);

I don't know why it passes the linter, but I am happy it does because otherwise I would have had to give up on standard.

Perhaps this quirk could be highlighted in the documentation? Seems like something that could drive many JS developers mad, especially now that async/await usage is becoming... wait for it... standard.

@taoeffect

This comment has been minimized.

Copy link
Author

commented May 19, 2016

Oops, this was totally my fault. I had added /* eslint-disable no-spaced-func, no-unexpected-multiline */ to the top of the file because I did not want to have create variables. But I should have instead followed the advice in RULES.md (which I'd forgotten) and simply done ;(await ... instead.

@taoeffect taoeffect closed this May 19, 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.
2 participants
You can’t perform that action at this time.