acorn-static-class-property-initializer
Partial support for static class properties in Acorn
Last updated 4 years ago by victor-homyakov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install acorn-static-class-property-initializer 
SYNC missed versions from official npm registry.

acorn-static-class-property-initializer

Partial support for static class properties from ES Class Fields & Static Properties Proposal in Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.

Purpose

Made to support static property initializers in React components written as ES6+ classes:

class EntityState extends Component {
    static propTypes = {
        entityState: PropTypes.string.isRequired
    };

    render() {
        return <div>{this.props.entityState}</div>;
    }
}

Usage

You can use module directly in order to get Acorn instance with plugin installed:

var acorn = require('acorn-static-class-property-initializer');

Or you can use inject.js to inject multiple plugins into Acorn:

var acorn = require('acorn');
var injectAcornJsx = require('acorn-jsx/inject');
var injectAcornStaticClassPropertyInitializer = require('acorn-static-class-property-initializer/inject');
injectAcornJsx(acorn);
injectAcornStaticClassPropertyInitializer(acorn);

Then, use the plugins option whenever you need to support static class properties while parsing:

var ast = acorn.parse(code, {
  plugins: {
      jsx: true, // true to enable JSX plugin
      staticClassPropertyInitializer: true // true to enable staticClassPropertyInitializer plugin
  }
});

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

1 Versions

  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 3
Last Day 0
Last Week 2
Last Month 5
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |