Skip to content

Commit

Permalink
Fix: async shorthand properties (fixes eslint#340) (eslint#341)
Browse files Browse the repository at this point in the history
* Fix: async shorthand properties (fixes eslint#340)
* Fix: and default parameters
  • Loading branch information
mysticatea authored Jun 15, 2017
1 parent ea08611 commit be85b8e
Show file tree
Hide file tree
Showing 7 changed files with 882 additions and 4 deletions.
13 changes: 9 additions & 4 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ function resetExtra() {


var tt = acorn.tokTypes,
getLineInfo = acorn.getLineInfo;
getLineInfo = acorn.getLineInfo,
lineBreak = acorn.lineBreak;

// custom type for JSX attribute values
tt.jsxAttrValueToken = {};
Expand Down Expand Up @@ -427,9 +428,13 @@ acorn.plugins.espree = function(instance) {
!prop.computed &&
prop.key.type === "Identifier" &&
prop.key.name === "async" &&
this.type !== tt.parenL &&
this.type !== tt.colon &&
!this.canInsertSemicolon()
(
this.type === tt.name ||
this.type === tt.num ||
this.type === tt.string ||
this.type === tt.bracketL
) &&
!lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
) {
this.parsePropertyName(prop, refShorthandDefaultPos);
isAsync = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
module.exports = {
"type": "Program",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"range": [
0,
9
],
"body": [
{
"type": "ExpressionStatement",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"range": [
0,
9
],
"expression": {
"type": "ObjectExpression",
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 8
}
},
"range": [
1,
8
],
"properties": [
{
"type": "Property",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
2,
7
],
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
2,
7
],
"name": "async"
},
"kind": "init",
"value": {
"type": "Identifier",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
2,
7
],
"name": "async"
}
}
]
}
}
],
"sourceType": "script",
"tokens": [
{
"type": "Punctuator",
"value": "(",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"range": [
0,
1
]
},
{
"type": "Punctuator",
"value": "{",
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
},
"range": [
1,
2
]
},
{
"type": "Identifier",
"value": "async",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
2,
7
]
},
{
"type": "Punctuator",
"value": "}",
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 8
}
},
"range": [
7,
8
]
},
{
"type": "Punctuator",
"value": ")",
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
},
"range": [
8,
9
]
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({async})
Loading

0 comments on commit be85b8e

Please sign in to comment.