;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/impure-state/expected.js:
--------------------------------------------------------------------------------
1 | class Foo extends React.Component {
2 | render() {
3 | this.props.foo;
4 | return
;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/impure-static-props/actual.js:
--------------------------------------------------------------------------------
1 | class Foo extends React.Component {
2 | static bar = 'bar';
3 |
4 | render() {
5 | this.props.foo;
6 | return
;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/impure-static-props/expected.js:
--------------------------------------------------------------------------------
1 | class Foo extends React.Component {
2 | static bar = 'bar';
3 |
4 | render() {
5 | this.props.foo;
6 | return
;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-class-expression/actual.js:
--------------------------------------------------------------------------------
1 | module.exports = class Foo extends React.Component {
2 | static propTypes = {
3 | foo: React.PropTypes.string.isRequired
4 | };
5 |
6 | render() {
7 | this.props.foo;
8 | return
;
9 | }
10 | };
11 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-class-expression/expected.js:
--------------------------------------------------------------------------------
1 | module.exports = function () {
2 | function Foo(props) {
3 | props.foo;
4 | return
;
5 | }
6 |
7 | Foo.propTypes = {
8 | foo: React.PropTypes.string.isRequired
9 | };
10 | return Foo;
11 | }();
12 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-no-props/actual.js:
--------------------------------------------------------------------------------
1 | class Foo extends React.Component {
2 | render() {
3 | this.props.foo;
4 | return
;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-no-props/expected.js:
--------------------------------------------------------------------------------
1 | function Foo(props) {
2 | props.foo;
3 | return
;
4 | }
5 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-props/actual.js:
--------------------------------------------------------------------------------
1 | class Foo extends React.Component {
2 | render() {
3 | return
;
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-props/expected.js:
--------------------------------------------------------------------------------
1 | function Foo(props) {
2 | return
;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-static-props/actual.js:
--------------------------------------------------------------------------------
1 | class Foo extends React.Component {
2 | static propTypes = {
3 | className: React.PropTypes.string
4 | };
5 |
6 | static defaultProps = {
7 | className: 'foo'
8 | };
9 |
10 | render() {
11 | return
;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/fixtures/pure-static-props/expected.js:
--------------------------------------------------------------------------------
1 | function Foo(props) {
2 | return
;
3 | }
4 |
5 | Foo.propTypes = {
6 | className: React.PropTypes.string
7 | };
8 | Foo.defaultProps = {
9 | className: 'foo'
10 | };
11 |
--------------------------------------------------------------------------------
/packages/babel-plugin-transform-react-pure-class-to-function/test/index.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const fs = require("fs");
3 | const assert = require("assert");
4 | const babel = require("babel-core");
5 | const plugin = require("../src/index");
6 |
7 | function trim(str) {
8 | return str.replace(/^\s+|\s+$/, "");
9 | }
10 |
11 | describe("fixtures", () => {
12 | const fixturesDir = path.join(__dirname, "fixtures");
13 |
14 | fs.readdirSync(fixturesDir).map((caseName) => {
15 | if (caseName === '.babelrc') return;
16 |
17 | it(caseName.split("-").join(" "), () => {
18 | const fixtureDir = path.join(fixturesDir, caseName);
19 | const actual = babel.transformFileSync(
20 | path.join(fixtureDir, "actual.js")
21 | ).code;
22 | const expected = fs.readFileSync(path.join(fixtureDir, "expected.js")).toString();
23 |
24 | assert.equal(trim(actual), trim(expected));
25 | });
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/packages/babel-preset-react-optimize/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | test
3 | node_modules
4 |
--------------------------------------------------------------------------------
/packages/babel-preset-react-optimize/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-preset-react-optimize",
3 | "version": "1.0.1",
4 | "description": "",
5 | "main": "lib/index.js",
6 | "license": "MIT",
7 | "author": "James Kyle
",
8 | "homepage": "https://github.com/thejameskyle/babel-react-optimize#readme",
9 | "repository": "https://github.com/thejameskyle/babel-react-optimize/tree/master/packages/babel-preset-react-optimize",
10 | "bugs": "https://github.com/thejameskyle/babel-react-optimize/issues",
11 | "keywords": [
12 | "babel-plugin",
13 | "react",
14 | "optimize"
15 | ],
16 | "dependencies": {
17 | "babel-plugin-transform-react-constant-elements": "^6.5.0",
18 | "babel-plugin-transform-react-inline-elements": "^6.6.5",
19 | "babel-plugin-transform-react-remove-prop-types": "^0.2.5",
20 | "babel-plugin-transform-react-pure-class-to-function": "^1.0.1"
21 | },
22 | "devDependencies": {}
23 | }
24 |
--------------------------------------------------------------------------------
/packages/babel-preset-react-optimize/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('babel-plugin-transform-react-constant-elements'),
4 | require('babel-plugin-transform-react-inline-elements'),
5 | require('babel-plugin-transform-react-remove-prop-types')['default'],
6 | require('babel-plugin-transform-react-pure-class-to-function')
7 | ]
8 | };
9 |
--------------------------------------------------------------------------------