GithubHelp home page GithubHelp logo

acorn-private-class-elements's Introduction

Helpers for supporting private class methods and fields for Acorn

NPM version

This is a plugin for Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.

It provides helpers for implementing support for private class elements. The emitted AST follows the ESTree experimental Class Features design.

License

This plugin is released under an MIT License.

acorn-private-class-elements's People

Contributors

adrianheine avatar coderaiser avatar coreyfarrell avatar marijnh avatar tchetwin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

acorn-private-class-elements's Issues

remove use of __proto__

Hi, node recently added a --disable-proto option to disable use of __proto__ due to security issues: nodejs/node#32279. Similarly, deno also recently removed support for __proto__: denoland/deno#4341. Would you consider removing the use of __proto__ in this package? The changes proposed in #10 would take care of it if merged.

Didn't handle error friendly

TEST.js:

'use strict';
Error.stackTraceLimit = 100;
const Parser = require('acorn').Parser.extend(require('acorn-class-fields'));
Parser.parse('a.#1=c;');

The error thrown is not friendly with loc info any more:

        if (!this._privateBoundNamesStack.length || !this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1][node.property.name]) {
                                          ^
TypeError: Cannot read property 'length' of undefined
    at Object.parseSubscript             (/node_modules/acorn-class-fields/node_modules/acorn-private-class-elements/index.js:101:43)
    at Object.pp$3.parseSubscripts       (/node_modules/acorn/dist/acorn.js:2104:26)
    at Object.pp$3.parseExprSubscripts   (/node_modules/acorn/dist/acorn.js:2092:23)
    at Object.pp$3.parseMaybeUnary       (/node_modules/acorn/dist/acorn.js:2066:19)
    at Object.parseMaybeUnary            (/node_modules/acorn-class-fields/node_modules/acorn-private-class-elements/index.js:112:29)
    at Object.pp$3.parseExprOps          (/node_modules/acorn/dist/acorn.js:2010:21)
    at Object.pp$3.parseMaybeConditional (/node_modules/acorn/dist/acorn.js:1993:21)
    at Object.pp$3.parseMaybeAssign      (/node_modules/acorn/dist/acorn.js:1968:21)
    at Object.pp$3.parseExpression       (/node_modules/acorn/dist/acorn.js:1933:21)
    at Object.pp$1.parseStatement        (/node_modules/acorn/dist/acorn.js:877:47)
    at Object.pp$1.parseTopLevel         (/node_modules/acorn/dist/acorn.js:746:23)
    at Object.parse                      (/node_modules/acorn/dist/acorn.js:553:17)
    at Function.parse                    (/node_modules/acorn/dist/acorn.js:576:37)
    at Object.<anonymous>                (/TEST.js:4:8)
    at Module._compile                   (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js     (internal/modules/cjs/loader.js:991:10)
    at Module.load                       (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load             (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain           (internal/modules/cjs/loader.js:1043:10)
    at                                   (internal/main/run_main_module.js:17:11)

Keyword support

The following throws an error:

class P {
  delete = 5;
}

with the above is supported in eg Babel. Yet the corresponding class method definition is fine:

class P {
  delete () {
  }
}

I wonder if we should run the parseIdentifier with liberal to cater to this flexibility? I'm not sure which would be exactly correct by the spec, but I feel like it likely would be similar to class definitions surely?

Support the new acorn@7 version

The newest version of acorn is 7 now, so could u remove the limitation of acorn@6 only?

OR I could make a PR if you wish.

latest version on npm is 0.2.0

... not 0.2.2 -- even though npm says that you published 22 days ago same that github says pushed the 0.2.2 version to github. I use acorn 7, so it's pretty necessary.

you must have mistakenly published the wrong version to npm.. the package.json has "version": "0.2.0"which is probably how it happened. temporarily as a workaround I've set my package.json to point to this repository. just lettin you know, though..

cheers 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.