Throw error for reserved words enum and await (#195)
* Throw error for reserved words enum and await when source type is module * Extract reserved word check into method * Fix tests
This commit is contained in:
committed by
Daniel Tschinder
parent
643124744f
commit
e260381e06
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:8)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:36)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:36)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:36)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:36)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:47)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:47)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:47)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:47)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to eval in strict mode (1:32)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:32)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to arguments in strict mode (1:32)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:32)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to eval in strict mode (1:34)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:34)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to eval in strict mode (1:34)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:34)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to arguments in strict mode (1:34)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:34)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to arguments in strict mode (1:34)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:34)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to eval in strict mode (1:32)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:32)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to eval in strict mode (1:32)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:32)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to arguments in strict mode (1:32)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:32)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Assigning to arguments in strict mode (1:32)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:32)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:41)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:41)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:41)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:41)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:9)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:9)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:9)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:9)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:42)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:42)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:42)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:42)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:10)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:10)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:10)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:10)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:47)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:47)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding package in strict mode (1:10)"
|
||||
}
|
||||
"throws": "package is a reserved word in strict mode (1:10)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:48)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:48)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:41)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:41)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:49)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:49)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:15)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:15)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:15)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:15)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:48)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:48)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding arguments in strict mode (1:48)"
|
||||
}
|
||||
"throws": "arguments is a reserved word in strict mode (1:48)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding implements in strict mode (1:37)"
|
||||
"throws": "implements is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding interface in strict mode (1:37)"
|
||||
"throws": "interface is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding package in strict mode (1:37)"
|
||||
"throws": "package is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding private in strict mode (1:37)"
|
||||
"throws": "private is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding protected in strict mode (1:37)"
|
||||
"throws": "protected is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding public in strict mode (1:37)"
|
||||
"throws": "public is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding static in strict mode (1:37)"
|
||||
"throws": "static is a reserved word in strict mode (1:37)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding static in strict mode (1:15)"
|
||||
}
|
||||
"throws": "static is a reserved word in strict mode (1:15)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding static in strict mode (1:9)"
|
||||
}
|
||||
"throws": "static is a reserved word in strict mode (1:9)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "The keyword 'static' is reserved (1:23)"
|
||||
"throws": "static is a reserved word in strict mode (1:23)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:11)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:11)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding package in strict mode (1:11)"
|
||||
}
|
||||
"throws": "package is a reserved word in strict mode (1:11)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding eval in strict mode (1:12)"
|
||||
}
|
||||
"throws": "eval is a reserved word in strict mode (1:12)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Binding package in strict mode (1:12)"
|
||||
}
|
||||
"throws": "package is a reserved word in strict mode (1:12)"
|
||||
}
|
||||
|
||||
2
test/fixtures/core/uncategorised/544/actual.js
vendored
Normal file
2
test/fixtures/core/uncategorised/544/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
const { public } = foo();
|
||||
3
test/fixtures/core/uncategorised/544/options.json
vendored
Normal file
3
test/fixtures/core/uncategorised/544/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "public is a reserved word in strict mode (2:8)"
|
||||
}
|
||||
1
test/fixtures/core/uncategorised/545/actual.js
vendored
Normal file
1
test/fixtures/core/uncategorised/545/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const { public } = foo();
|
||||
4
test/fixtures/core/uncategorised/545/options.json
vendored
Normal file
4
test/fixtures/core/uncategorised/545/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"throws": "public is a reserved word in strict mode (1:8)"
|
||||
}
|
||||
1
test/fixtures/core/uncategorised/546/actual.js
vendored
Normal file
1
test/fixtures/core/uncategorised/546/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const { public } = foo();
|
||||
172
test/fixtures/core/uncategorised/546/expected.json
vendored
Normal file
172
test/fixtures/core/uncategorised/546/expected.json
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 6,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 6,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 8,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"shorthand": true,
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"identifierName": "public"
|
||||
},
|
||||
"name": "public"
|
||||
},
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"identifierName": "public"
|
||||
},
|
||||
"name": "public"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": {
|
||||
"type": "CallExpression",
|
||||
"start": 19,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"arguments": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/core/uncategorised/546/options.json
vendored
Normal file
3
test/fixtures/core/uncategorised/546/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceType": "script"
|
||||
}
|
||||
2
test/fixtures/core/uncategorised/547/actual.js
vendored
Normal file
2
test/fixtures/core/uncategorised/547/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
const { arguments } = foo();
|
||||
3
test/fixtures/core/uncategorised/547/options.json
vendored
Normal file
3
test/fixtures/core/uncategorised/547/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "arguments is a reserved word in strict mode (2:8)"
|
||||
}
|
||||
1
test/fixtures/core/uncategorised/548/actual.js
vendored
Normal file
1
test/fixtures/core/uncategorised/548/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const { arguments } = foo();
|
||||
4
test/fixtures/core/uncategorised/548/options.json
vendored
Normal file
4
test/fixtures/core/uncategorised/548/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"throws": "arguments is a reserved word in strict mode (1:8)"
|
||||
}
|
||||
1
test/fixtures/core/uncategorised/549/actual.js
vendored
Normal file
1
test/fixtures/core/uncategorised/549/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const { arguments } = foo();
|
||||
172
test/fixtures/core/uncategorised/549/expected.json
vendored
Normal file
172
test/fixtures/core/uncategorised/549/expected.json
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 6,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 6,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 8,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"shorthand": true,
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "arguments"
|
||||
},
|
||||
"name": "arguments"
|
||||
},
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "arguments"
|
||||
},
|
||||
"name": "arguments"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": {
|
||||
"type": "CallExpression",
|
||||
"start": 22,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 22,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"arguments": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/core/uncategorised/549/options.json
vendored
Normal file
3
test/fixtures/core/uncategorised/549/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceType": "script"
|
||||
}
|
||||
Reference in New Issue
Block a user