eslint / espree

An Esprima-compatible JavaScript parser
BSD 2-Clause "Simplified" License
2.26k stars 189 forks source link

Update: Support top-level await and regexp match indices #505

Closed nzakas closed 3 years ago

nzakas commented 3 years ago

Updates Acorn and adds tests for top-level await and regexp match indices.

Refs https://github.com/eslint/eslint/issues/14632 Refs https://github.com/eslint/eslint/issues/14640

nzakas commented 3 years ago

Okay, should be all set now.

mdjermanovic commented 3 years ago

I think we need the top-level await tests to have modules word in the file path. Otherwise, they'll be parsed both with sourceType: "script" and sourceType: "module"

https://github.com/eslint/espree/blob/c8ca49a281eb74bb81e9bc3a60300011e8b29e8d/tests/lib/ecma-version.js#L38

(that "Only" in the variable name is misleading)

I can see this test in the output, it's passing only because the current Acorn allows that:

  ecmaVersion
    Scripts
      /13/top-level-await/top-await
        √ should parse correctly when sourceType is script

We can make a modules subdir in ecma-version/13: ecma-version/13/modules/top-level-await/, the same way as it was done in ecma-version/11

nzakas commented 3 years ago

I updated the tests. I’d like to see if there’s a new Acorn release in the next couple days with the top-level await fix.

nzakas commented 3 years ago

A new release of Acorn was published, so added that.