Socket
Socket
Sign inDemoInstall

acorn-class-fields

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn-class-fields - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

4

.eslintrc.json

@@ -84,3 +84,3 @@ {

"getter-return": "error",
"global-require": "error",
"global-require": "warn",
"guard-for-in": "error",

@@ -134,3 +134,3 @@ "handle-callback-err": "error",

"no-await-in-loop": "error",
"no-bitwise": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",

@@ -137,0 +137,0 @@ "no-caller": "error",

@@ -0,1 +1,10 @@

## 0.3.2 (2020-04-24)
* Make compatible with acorn@7
* Use injected acorn instance if available
* Evaluate class heritage with outer private environment
* Don't allow private element access on `super`
* Uses `Object.getPrototypeOf` if available instead of `__proto__`
* Fix usage of super in field initializers
## 0.3.1 (2019-02-09)

@@ -2,0 +11,0 @@

"use strict"
const acorn = require("acorn")
const tt = acorn.tokTypes
const privateClassElements = require("acorn-private-class-elements")
function maybeParseFieldValue(field) {
if (this.eat(tt.eq)) {
const oldInFieldValue = this._inFieldValue
this._inFieldValue = true
field.value = this.parseExpression()
this._inFieldValue = oldInFieldValue
} else field.value = null
}
module.exports = function(Parser) {
const acorn = Parser.acorn || require("acorn")
const tt = acorn.tokTypes
module.exports = function(Parser) {
Parser = privateClassElements(Parser)
return class extends Parser {
_maybeParseFieldValue(field) {
if (this.eat(tt.eq)) {
const oldInFieldValue = this._inFieldValue
this._inFieldValue = true
field.value = this.parseExpression()
this._inFieldValue = oldInFieldValue
} else field.value = null
}
// Parse fields

@@ -42,3 +43,5 @@ parseClassElement(_constructorAllowsSuper) {

}
maybeParseFieldValue.call(this, node)
this.enterScope(64 | 2 | 1) // See acorn's scopeflags.js
this._maybeParseFieldValue(node)
this.exitScope()
this.finishNode(node, "FieldDefinition")

@@ -45,0 +48,0 @@ this.semicolon()

@@ -22,16 +22,16 @@ {

"peerDependencies": {
"acorn": "^6.0.0"
"acorn": "^6.0.0 || ^7.0.0"
},
"version": "0.3.1",
"version": "0.3.2",
"devDependencies": {
"acorn": "^6.1.0",
"eslint": "^5.13.0",
"eslint-plugin-node": "^8.0.1",
"mocha": "^5.2.0",
"test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d",
"acorn": "^6.0.0 || ^7.0.0",
"eslint": "^6",
"eslint-plugin-node": "^11",
"mocha": "^7",
"test262": "git+https://github.com/tc39/test262.git#57fa74b170e9554bfe89a29c10de2447fe7d3b27",
"test262-parser-runner": "^0.5.0"
},
"dependencies": {
"acorn-private-class-elements": "^0.1.1"
"acorn-private-class-elements": "^0.2.5"
}
}

@@ -10,7 +10,7 @@ "use strict"

const unsupportedFeatures = [
"BigInt",
"class-methods-private",
"class-static-fields-public",
"class-static-fields-private",
"class-static-methods-private"
"class-static-methods-private",
"optional-chaining"
]

@@ -21,3 +21,3 @@

run(
(content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 9}),
(content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 11}),
{

@@ -24,0 +24,0 @@ testsDirectory: path.dirname(require.resolve("test262/package.json")),

@@ -29,2 +29,6 @@ "use strict"

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

@@ -42,2 +46,18 @@ x = 0;

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 {

@@ -63,3 +83,3 @@ #x = 0;

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)")

@@ -66,0 +86,0 @@ testFail("class A { #a; a() { this.# a } }", "Unexpected token (1:27)")

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc