-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add examples/ that strip propTypes for production with babel plugin
- Loading branch information
Showing
7 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["es2015", "stage-0", "react"], | ||
"plugins": ["transform-react-remove-prop-types"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "examples", | ||
"version": "0.0.0", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel src --out-dir lib", | ||
"build-watch": "babel src --watch --out-dir lib", | ||
"clear": "rm -rf ./lib", | ||
"pretest": "npm run build", | ||
"start": "npm test", | ||
"test": "mocha", | ||
"test-watch": "mocha --watch", | ||
"watch": "npm run build-watch & npm run test-watch" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/joonhocho/proptypes-parser.git" | ||
}, | ||
"author": "Joon Ho Cho", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/joonhocho/proptypes-parser/issues" | ||
}, | ||
"homepage": "https://github.com/joonhocho/proptypes-parser#readme", | ||
"dependencies": { | ||
"react": "^15.1.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.10.1", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.2.7", | ||
"babel-preset-es2015": "^6.9.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"babel-register": "^6.9.0", | ||
"chai": "^3.5.0", | ||
"mocha": "^2.5.3", | ||
"proptypes-parser": "^0.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, {Component} from 'react'; | ||
import {PT} from '../../lib'; | ||
|
||
class ES6 extends Component { | ||
static propTypes = PT`{ | ||
value: Number! | ||
}`; | ||
render() { | ||
return (<div/>); | ||
} | ||
} | ||
|
||
|
||
const ES5 = React.createClass({ | ||
propTypes: PT`{ | ||
value: Number! | ||
}`, | ||
render: function() { | ||
return (<div/>); | ||
}, | ||
}); | ||
|
||
|
||
class ES6Assign extends Component { | ||
render() { | ||
return (<div/>); | ||
} | ||
} | ||
ES6Assign.propTypes = PT`{ | ||
value: Number! | ||
}`; | ||
|
||
|
||
const ES5Assign = React.createClass({ | ||
render: function() { | ||
return (<div/>); | ||
} | ||
}); | ||
ES5Assign.propTypes = PT`{ | ||
value: Number! | ||
}`; | ||
|
||
|
||
function FuncAssign() { | ||
return (<div/>); | ||
} | ||
FuncAssign.propTypes = PT`{ | ||
value: Number! | ||
}`; | ||
|
||
|
||
class ES6VarAssign extends Component { | ||
render() { | ||
return (<div/>); | ||
} | ||
} | ||
const fPropTypes = PT`{ | ||
value: Number! | ||
}`; | ||
ES6VarAssign.propTypes = fPropTypes; | ||
|
||
|
||
export { | ||
ES6, ES5, ES6Assign, ES5Assign, FuncAssign, ES6VarAssign, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {describe, it} from 'mocha'; | ||
import {expect} from 'chai'; | ||
import {ES6, ES5, ES6Assign, ES5Assign, FuncAssign, ES6VarAssign} from '../lib'; | ||
|
||
|
||
describe('PT', () => { | ||
it('babel plugin should remove ES6.propTypes', () => { | ||
expect(ES6.propTypes).to.be.undefined; | ||
}); | ||
|
||
it('babel plugin should remove ES5.propTypes', () => { | ||
expect(ES5.propTypes).to.be.undefined; | ||
}); | ||
|
||
it('babel plugin should remove ES6Assign.propTypes', () => { | ||
expect(ES6Assign.propTypes).to.be.undefined; | ||
}); | ||
|
||
it('babel plugin should remove ES5Assign.propTypes', () => { | ||
expect(ES5Assign.propTypes).to.be.undefined; | ||
}); | ||
|
||
it('babel plugin should remove FuncAssign.propTypes', () => { | ||
expect(FuncAssign.propTypes).to.be.undefined; | ||
}); | ||
|
||
it('babel plugin should remove ES6VarAssign.propTypes', () => { | ||
expect(ES6VarAssign.propTypes).to.be.undefined; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--compilers js:babel-register | ||
--require ./test/setup.js | ||
--reporter spec | ||
--timeout 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var chai = require('chai'); | ||
chai.use(require('chai-as-promised')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters