acorn-private-class-elements
Advanced tools
Comparing version 0.2.0 to 0.2.3
@@ -84,3 +84,3 @@ { | ||
"getter-return": "error", | ||
"global-require": "error", | ||
"global-require": "warn", | ||
"guard-for-in": "error", | ||
@@ -87,0 +87,0 @@ "handle-callback-err": "error", |
@@ -0,1 +1,8 @@ | ||
## 0.2.3 (2020-04-22) | ||
(Skipped 0.2.1 and 0.2.2 because I accidentally called 0.2.0 0.2.2 in git) | ||
* Use injected acorn instance if available | ||
* Uses `Object.getPrototypeOf` if available instead of `__proto__` | ||
## 0.2.0 (2020-03-07) | ||
@@ -2,0 +9,0 @@ |
38
index.js
"use strict" | ||
const acorn = require("acorn") | ||
if (acorn.version.indexOf("6.") != 0 && acorn.version.indexOf("6.0.") == 0 && acorn.version.indexOf("7.") != 0) { | ||
throw new Error(`acorn-private-class-elements requires acorn@^6.1.0 or acorn@7.0.0, not ${acorn.version}`) | ||
const getPrototype = Object.getPrototypeOf || (o => o.__proto__) | ||
const getAcorn = Parser => { | ||
if (Parser.acorn) return Parser.acorn | ||
const acorn = require("acorn") | ||
if (acorn.version.indexOf("6.") != 0 && acorn.version.indexOf("6.0.") == 0 && acorn.version.indexOf("7.") != 0) { | ||
throw new Error(`acorn-private-class-elements requires acorn@^6.1.0 or acorn@7.0.0, not ${acorn.version}`) | ||
} | ||
// Make sure `Parser` comes from the same acorn as we `require`d, | ||
// otherwise the comparisons fail. | ||
for (let cur = Parser; cur && cur !== acorn.Parser; cur = getPrototype(cur)) { | ||
if (cur !== acorn.Parser) { | ||
throw new Error("acorn-private-class-elements does not support mixing different acorn copies") | ||
} | ||
} | ||
return acorn | ||
} | ||
const tt = acorn.tokTypes | ||
const TokenType = acorn.TokenType | ||
@@ -16,11 +30,3 @@ module.exports = function(Parser) { | ||
// Make sure `Parser` comes from the same acorn as our `tt`, | ||
// otherwise the comparisons fail. | ||
let cur = Parser | ||
while (cur && cur !== acorn.Parser) { | ||
cur = cur.__proto__ | ||
} | ||
if (cur !== acorn.Parser) { | ||
throw new Error("acorn-private-class-elements does not support mixing different acorn copies") | ||
} | ||
const acorn = getAcorn(Parser) | ||
@@ -94,3 +100,3 @@ Parser = class extends Parser { | ||
parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow) { | ||
if (!this.eat(tt.dot)) { | ||
if (!this.eat(acorn.tokTypes.dot)) { | ||
return super.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow) | ||
@@ -123,4 +129,4 @@ } | ||
} | ||
Parser.prototype.privateNameToken = new TokenType("privateName") | ||
Parser.prototype.privateNameToken = new acorn.TokenType("privateName") | ||
return Parser | ||
} |
@@ -23,3 +23,3 @@ { | ||
}, | ||
"version": "0.2.0", | ||
"version": "0.2.3", | ||
"devDependencies": { | ||
@@ -26,0 +26,0 @@ "acorn": "^7.0.0", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17712
8
429