acorn-static-class-features
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -225,3 +225,3 @@ { | ||
"no-void": "error", | ||
"no-warning-comments": "error", | ||
"no-warning-comments": "warn", | ||
"no-whitespace-before-property": "error", | ||
@@ -249,3 +249,3 @@ "no-with": "error", | ||
"prefer-reflect": "off", | ||
"prefer-rest-params": "error", | ||
"prefer-rest-params": "off", | ||
"prefer-spread": "error", | ||
@@ -263,3 +263,3 @@ "prefer-template": "error", | ||
"error", | ||
"last" | ||
"first" | ||
], | ||
@@ -266,0 +266,0 @@ "sort-imports": "error", |
@@ -0,3 +1,7 @@ | ||
## 0.1.1 (2018-11-06) | ||
* Adapt to changes in acorn 6.0.3 | ||
## 0.1.0 (2018-09-14) | ||
Initial release |
11
index.js
@@ -63,3 +63,3 @@ "use strict" | ||
// Parse private fields | ||
parseClassElement() { | ||
parseClassElement(_constructorAllowsSuper) { | ||
if (this.eat(tt.semi)) return null | ||
@@ -70,3 +70,3 @@ | ||
const tryContextual = (k, noLineBreak) => { | ||
if (typeof noLineBreak == 'undefined') noLineBreak = false | ||
if (typeof noLineBreak == "undefined") noLineBreak = false | ||
const start = this.start, startLoc = this.startLoc | ||
@@ -84,3 +84,3 @@ if (!this.eatContextual(k)) return false | ||
node.static = tryContextual("static") | ||
if (!node.static) return super.parseClassElement() | ||
if (!node.static) return super.parseClassElement.apply(this, arguments) | ||
@@ -160,7 +160,7 @@ let isGenerator = this.eat(tt.star) | ||
// Parse public static fields | ||
parseClassMethod(method, isGenerator, isAsync) { | ||
parseClassMethod(method, isGenerator, isAsync, _allowsDirectSuper) { | ||
if (isGenerator || isAsync || method.kind != "method" || !method.static || this.options.ecmaVersion < 8 || this.type == tt.parenL) { | ||
const oldInPrivateClassMethod = this._inPrivateClassMethod | ||
this._inPrivateClassMethod = method.key.type == "PrivateName" | ||
const ret = super.parseClassMethod(method, isGenerator, isAsync) | ||
const ret = super.parseClassMethod.apply(this, arguments) | ||
this._inPrivateClassMethod = oldInPrivateClassMethod | ||
@@ -221,2 +221,3 @@ return ret | ||
// Prohibit direct super in private methods | ||
// FIXME: This is not necessary in acorn >= 6.0.3 | ||
parseExprAtom(refDestructuringErrors) { | ||
@@ -223,0 +224,0 @@ const atom = super.parseExprAtom(refDestructuringErrors) |
@@ -24,11 +24,11 @@ { | ||
}, | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"devDependencies": { | ||
"acorn": "^6.0.0", | ||
"acorn": "^6.0.4", | ||
"eslint": "^5.5.0", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-node": "^8.0.0", | ||
"mocha": "^5.2.0", | ||
"test262": "git+https://github.com/tc39/test262.git#e286bfa00086226f781a3ed4e0a6295634b8ed11", | ||
"test262": "git+https://github.com/tc39/test262.git#c0ffc8f6da0f2a7ec87afb87ec5f2664b1ba57ec", | ||
"test262-parser-runner": "^0.4.0" | ||
} | ||
} |
@@ -10,3 +10,5 @@ "use strict" | ||
const unsupportedFeatures = [ | ||
"class-fields-public" | ||
"BigInt", | ||
"class-fields-public", | ||
"class-methods-private" | ||
] | ||
@@ -13,0 +15,0 @@ |
@@ -39,3 +39,3 @@ "use strict" | ||
testFail("class A { static a = () => arguments }", "A static class field initializer may not contain arguments (1:27)") | ||
testFail("class A { static a = () => super() }", "A static class field initializer may not contain super (1:27)") | ||
testFail("class A { static a = () => super() }", "'super' keyword outside a method (1:27)") | ||
testFail("class A { static # a }", "Unexpected token (1:19)") | ||
@@ -203,5 +203,5 @@ testFail("class A { static #a; a() { A.# a } }", "Unexpected token (1:31)") | ||
} }, | ||
]; | ||
] | ||
[ | ||
;[ | ||
{ body: "static x", passes: true, ast: start => newNode(start, { | ||
@@ -328,4 +328,4 @@ type: "FieldDefinition", | ||
classes.forEach(input => { | ||
const text = input.text, options = input.options || {}, ast = input.ast; | ||
(passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options) | ||
const text = input.text, options = input.options || {}, ast = input.ast | ||
;(passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options) | ||
}) | ||
@@ -347,3 +347,3 @@ }) | ||
testFail("class A{ static # a() {}}", "Unexpected token (1:18)") | ||
testFail("class C{ static #method() { super(); } };", "A class method that is not a constructor may not contain a direct super (1:28)") | ||
testFail("class C{ static #method() { super(); } };", "super() call outside constructor of a subclass (1:28)") | ||
test("class C{ static #method() { super.y(); } };") | ||
@@ -408,6 +408,7 @@ | ||
classes.forEach(input => { | ||
const text = input.text, options = input.options || {}, ast = input.ast; | ||
(passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options) | ||
const text = input.text, options = input.options || {}, ast = input.ast | ||
;(passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options) | ||
}) | ||
}) | ||
test("class A extends B { constructor() { super() } }") | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34796
924