Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acorn 7 support #8

Merged
merged 2 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ module.exports = function(Parser) {
(node.key.type === "Literal" && node.key.value === "constructor")) {
this.raise(node.key.start, "Classes may not have a field called constructor")
}
this.enterScope(67);
maybeParseFieldValue.call(this, node)
this.exitScope();
this.finishNode(node, "FieldDefinition")
this.semicolon()
return node
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
"lint": "eslint -c .eslintrc.json ."
},
"peerDependencies": {
"acorn": "^6.0.0"
"acorn": "^6.0.0 || ^7.0.0"
},
"version": "0.3.1",
"devDependencies": {
"acorn": "^6.1.0",
"acorn": "^6.0.0 || ^7.0.0",
"eslint": "^5.13.0",
"eslint-plugin-node": "^8.0.1",
"mocha": "^5.2.0",
"test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d",
"test262-parser-runner": "^0.5.0"
},
"dependencies": {
"acorn-private-class-elements": "^0.1.1"
"acorn-private-class-elements": "^0.2.0"
}
}
22 changes: 21 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function testFail(text, expectedResult, additionalOptions) {
const newNode = (start, props) => Object.assign(new acorn.Node({options: {}}, start), props)

describe("acorn-class-fields", function () {
test(`class P extends Q {
x = super.x
}`)

test(`class Counter extends HTMLElement {
x = 0;
Expand All @@ -38,6 +42,22 @@ describe("acorn-class-fields", function () {
}
}`)

test(`
class AsyncIterPipe{
static get [ Symbol.species](){
return Promise
}
static get Closing(){
return Closing
}
static get controllerSignals(){ return controllerSignals}
static get listenerBinding(){ return listenerBinding}
// state
done= false
}
`)

test(`class Counter extends HTMLElement {
#x = 0;
Expand All @@ -58,7 +78,7 @@ describe("acorn-class-fields", function () {
testFail("class A { constructor = 4 }", "Classes may not have a field called constructor (1:10)")
testFail("class A { #constructor = 4 }", "Classes may not have a private element named constructor (1:10)")
testFail("class A { a = () => arguments }", "A class field initializer may not contain arguments (1:20)")
testFail("class A { a = () => super() }", "'super' keyword outside a method (1:20)")
testFail("class A { a = () => super() }", "super() call outside constructor of a subclass (1:20)")
testFail("class A { # a }", "Unexpected token (1:10)")
testFail("class A { #a; a() { this.# a } }", "Unexpected token (1:27)")

Expand Down