Comments (8)
from espree.
Ah yes, I've run into this as well. I'll need to dig into the spec a bit to figure out the right thing to do (I'm not sure if ASI means the semicolon is inserted at the end of input in this case or immediately after the paren).
from espree.
This annoyed me as I was working on the token API, but I looked at the spec's rules for ASI, which seem to indicate that this is the correct behavior.
a semicolon is automatically inserted before the offending token
Then in an example,
{ 1
2 } 3
gets transformed into
{ 1
;2 ;} 3;
from espree.
And more relevant to this case in particular:
When, as the program is parsed from left to right, the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream as a single complete ECMAScript Program, then a semicolon is automatically inserted at the end of the input stream.
(Emphasis mine)
from espree.
Thanks for the research, that matched up with my expectation. So it seems like we are doing the right thing in this case.
from espree.
Thanks for the clarification 🍻.
from espree.
is this still considered the right behavior?
https://github.com/jquery/esprima seems to not have this issue any more
a()
{
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"type": "Program",
"body": [
{
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"type": "ExpressionStatement",
"expression": {
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"type": "CallExpression",
"callee": {
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"type": "Identifier",
"name": "a"
},
"arguments": []
}
}
],
"sourceType": "script"
}
from espree.
the problem that i found is that when comment
option is set to true, the comment range overlaps with node ranges and it's very hard to identify where the comment belongs to
e.g.
// nodes
{
type: 'Identifier',
range: [20, 36]
}
/// comments
{
type: 'Line',
range: [25, 36]
from espree.
Related Issues (20)
- Please export `TokenTranslator` for reusing outside for ESLint plugins HOT 4
- Error parsing file starting with '#!/usr/bin/env node' HOT 2
- support import assertions HOT 1
- as token type: Identifier -> Punctuator HOT 3
- How to use from a script tag? HOT 1
- Not able to access parent node from current node. HOT 2
- Set up release-please HOT 1
- Set up scripts/lint-staged to match those in eslint repo HOT 3
- remove sourcemap url HOT 7
- typing for parse() HOT 1
- Support for `using` keyword HOT 1
- # ⚠️ npm 6.x no extra double-dash: npm init @eslint/config --config semistandard HOT 2
- add npm install step to release-please workflow (#573) (d8900c1) run tests on Node.js v20 (#571) (adf478e) set up release-please (#569) (abda10f) upgrade [email protected] (#574) (8e73f11) HOT 1
- Invalid regular expression flag HOT 2
- 9 Failing tests on project install HOT 1
- espree improvements as an acorn plugin extension [RFC] HOT 1
- Is it possible to configure tokenize method to return hyphenated word as one token? HOT 1
- Not ES2020 HOT 1
- Convert into monorepo HOT 16
- Change Request: replace `npm-run-all` by `npm-run-all2` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espree.