This repository has been archived by the owner on May 19, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ES2016 check for simple parameter list in strict mode (#106)
* Slightly simplify logic * Implement ES2016 check for simple parameter list in strict mode See e.g. ECMA-262 7.0 14.1.2: > It is a Syntax Error if ContainsUseStrict of FunctionBody is true and > IsSimpleParameterList of FormalParameters is false. Similar clauses cover arrow functions, generator functions, methods, and generator methods, as well as async functions and async arrow functions.
- Loading branch information
Showing
31 changed files
with
422 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/fixtures/es2016/simple-parameter-list/array-pattern-default/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function a([ option1, option2 ] = []) { | ||
"use strict"; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Non-simple parameter in strict mode (1:11)" | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/es2016/simple-parameter-list/array-pattern/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function a([ option1, option2 ]) { | ||
"use strict"; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/es2016/simple-parameter-list/array-pattern/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Non-simple parameter in strict mode (1:11)" | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/es2016/simple-parameter-list/arrow-function-concise-body/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var a = (options = {}) => options; |
170 changes: 170 additions & 0 deletions
170
test/fixtures/es2016/simple-parameter-list/arrow-function-concise-body/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 34, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 34 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 34, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 34 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start": 0, | ||
"end": 34, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 34 | ||
} | ||
}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start": 4, | ||
"end": 33, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 33 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 4, | ||
"end": 5, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 5 | ||
}, | ||
"identifierName": "a" | ||
}, | ||
"name": "a" | ||
}, | ||
"init": { | ||
"type": "ArrowFunctionExpression", | ||
"start": 8, | ||
"end": 33, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 8 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 33 | ||
} | ||
}, | ||
"id": null, | ||
"generator": false, | ||
"expression": true, | ||
"async": false, | ||
"params": [ | ||
{ | ||
"type": "AssignmentPattern", | ||
"start": 9, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"left": { | ||
"type": "Identifier", | ||
"start": 9, | ||
"end": 16, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 16 | ||
}, | ||
"identifierName": "options" | ||
}, | ||
"name": "options" | ||
}, | ||
"right": { | ||
"type": "ObjectExpression", | ||
"start": 19, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 19 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"properties": [] | ||
} | ||
} | ||
], | ||
"body": { | ||
"type": "Identifier", | ||
"start": 26, | ||
"end": 33, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 26 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 33 | ||
}, | ||
"identifierName": "options" | ||
}, | ||
"name": "options" | ||
} | ||
} | ||
} | ||
], | ||
"kind": "var" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/es2016/simple-parameter-list/arrow-function/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var a = (options = {}) => { | ||
"use strict"; | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/es2016/simple-parameter-list/arrow-function/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Non-simple parameter in strict mode (1:9)" | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/es2016/simple-parameter-list/async-arrow-function-concise-body/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var a = async (options = {}) => options; |
Oops, something went wrong.