├── .babelrc
├── .builderrc
├── .editorconfig
├── .gitignore
├── .npmignore
├── .travis.yml
├── CONTRIBUTING.md
├── DEVELOPMENT.md
├── LICENSE.txt
├── README.md
├── demo
├── app.jsx
└── index.html
├── dist
├── formidable-react-component-boilerplate.js
├── formidable-react-component-boilerplate.js.map
├── formidable-react-component-boilerplate.min.js
└── formidable-react-component-boilerplate.min.js.map
├── package.json
├── src
├── components
│ └── formidable-react-component-boilerplate.jsx
└── index.js
└── test
└── client
├── main.js
├── spec
└── components
│ └── formidable-react-component-boilerplate.spec.jsx
└── test.html
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "stage": 0,
3 | "nonStandard": true
4 | }
5 |
--------------------------------------------------------------------------------
/.builderrc:
--------------------------------------------------------------------------------
1 | ---
2 | archetypes:
3 | - builder-react-component
4 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | max_line_length = 100
12 |
13 | [*.md]
14 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### SublimeText ###
2 | *.sublime-workspace
3 |
4 | ### OSX ###
5 | .DS_Store
6 | .AppleDouble
7 | .LSOverride
8 | Icon
9 |
10 | # Thumbnails
11 | ._*
12 |
13 | # Files that might appear on external disk
14 | .Spotlight-V100
15 | .Trashes
16 |
17 | ### Windows ###
18 | # Windows image file caches
19 | Thumbs.db
20 | ehthumbs.db
21 |
22 | # Folder config file
23 | Desktop.ini
24 |
25 | # Recycle Bin used on file shares
26 | $RECYCLE.BIN/
27 |
28 | # App specific
29 |
30 | coverage
31 | node_modules
32 | bower_components
33 | .tmp
34 | lib
35 | npm-debug.log*
36 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Cruft
2 | *.sublime-workspace
3 | .DS_Store
4 | .AppleDouble
5 | .LSOverride
6 | Icon
7 | ._*
8 | .Spotlight-V100
9 | .Trashes
10 | Thumbs.db
11 | ehthumbs.db
12 | Desktop.ini
13 | $RECYCLE.BIN/
14 | .tmp
15 | npm-debug.log*
16 |
17 | # Code / build
18 | coverage
19 | node_modules
20 | bower_components
21 | demo
22 | test
23 | karma*
24 | webpack*
25 | .eslint*
26 | .editor*
27 | .travis*
28 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - "0.10"
5 | - "0.12"
6 | - "4.2"
7 | - "5.0"
8 |
9 | # Use container-based Travis infrastructure.
10 | sudo: false
11 |
12 | branches:
13 | only:
14 | - master
15 |
16 | env:
17 | matrix:
18 | - NPM_3=true
19 | - NPM_3=false
20 |
21 | before_install:
22 | # GUI for real browsers.
23 | - export DISPLAY=:99.0
24 | - sh -e /etc/init.d/xvfb start
25 |
26 | # Potentially update to npm 3
27 | - 'if [ "$NPM_3" = true ]; then npm install -g npm@3; else true; fi'
28 |
29 | script:
30 | - npm --version
31 | - node_modules/.bin/builder run check-ci
32 |
33 | # Prune deps to just production and ensure we can still build
34 | - npm prune --production
35 | - node_modules/.bin/builder run build
36 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ============
3 |
4 | Thanks for helping out!
5 |
6 | ## Development
7 |
8 | Run `builder run open-hot` or `builder run open-dev` to run a webpack dev server
9 | with component examples.
10 |
11 | ## Checks, Tests
12 |
13 | Run `builder run check` before committing.
14 |
15 | ## Dist
16 |
17 | Please do not commit changes to files in `dist`.
18 | These files are only committed when we tag releases.
19 |
20 | ## Generator Compatibility
21 |
22 | All boilerplate components should be named
23 | `formidable-react-component-boilerplate` or
24 | `FormidableReactComponentBoilerplate` as appropriate.
25 |
26 | `src/components/formidable-react-component-boilerplate.jsx` and
27 | `test/client/spec/components/formidable-react-component-boilerplate.spec.jsx`
28 | SHOULD NOT be moved or renamed
29 |
--------------------------------------------------------------------------------
/DEVELOPMENT.md:
--------------------------------------------------------------------------------
1 | Development
2 | ===========
3 |
4 | We use [builder][] and `npm` to control all aspects of development and
5 | publishing.
6 |
7 | As a preliminary matter, please update your shell to include
8 | `./node_modules/.bin` in `PATH` like:
9 |
10 | ```sh
11 | export PATH="${PATH}:./node_modules/.bin"
12 | ```
13 |
14 | So you can type `builder` instead of `./node_modules/.bin/builder` for all
15 | commands.
16 |
17 |
18 | ## Build
19 |
20 | Build for production use (NPM, bower, etc) and create `dist` UMD bundles
21 | (min'ed, non-min'ed)
22 |
23 | ```
24 | $ builder run build
25 | ```
26 |
27 | Note that `dist/` files are only updated and committed on **tagged releases**.
28 |
29 |
30 | ## Development
31 |
32 | All development tasks consist of watching the demo bundle, the test bundle
33 | and launching a browser pointed to the demo page.
34 |
35 | Run the `demo` application with watched rebuilds either doing:
36 |
37 | ### Basic Watched Builds
38 |
39 | ```sh
40 | $ builder run dev # dev test/app server
41 | $ builder run open-dev # (OR) dev servers _and a browser window opens!_
42 | ```
43 |
44 | ### Watched Builds + Hot Reloading
45 |
46 | Same as above, but with hot reloading of React components.
47 |
48 | ```sh
49 | $ builder run hot # hot test/app server
50 | $ builder run open-hot # (OR) hot servers _and a browser window opens!_
51 | ```
52 |
53 | From there, using either `dev` or `hot`, you can see:
54 |
55 | * Demo app: [127.0.0.1:3000](http://127.0.0.1:3000/)
56 | * Client tests: [127.0.0.1:3001/test/client/test.html](http://127.0.0.1:3001/test/client/test.html)
57 |
58 |
59 | ## Programming Guide
60 |
61 | ### Logging
62 |
63 | We use the following basic pattern for logging:
64 |
65 | ```js
66 | if (process.env.NODE_ENV !== "production") {
67 | /* eslint-disable no-console */
68 | if (typeof console !== "undefined" && console.warn) {
69 | console.warn("Oh noes! bad things happened.");
70 | }
71 | /* eslint-enable no-console */
72 | }
73 | ```
74 |
75 | Replace `console.warn` in the condtional + method call as appropriate.
76 |
77 | Breaking this down:
78 |
79 | * `process.env.NODE_ENV !== "production"` - This part removes all traces of
80 | the code in the production bundle, to save on file size. This _also_ means
81 | that no warnings will be displayed in production.
82 | * `typeof console !== "undefined" && console.METHOD` - A permissive check to
83 | make sure the `console` object exists and can use the appropriate `METHOD` -
84 | `warn`, `info`, etc.
85 |
86 | To signal production mode to the webpack build, declare the `NODE_ENV` variable:
87 |
88 | ```js
89 | new webpack.DefinePlugin({
90 | "process.env.NODE_ENV": JSON.stringify("production")
91 | })
92 | ```
93 |
94 | Unfortunately, we need to do _all_ of this every time to have Uglify properly
95 | drop the code, but with this trick, the production bundle has no change in code
96 | size.
97 |
98 |
99 | ## Quality
100 |
101 | ### In Development
102 |
103 | During development, you are expected to be running either:
104 |
105 | ```sh
106 | $ builder run dev
107 | ```
108 |
109 | to build the lib and test files. With these running, you can run the faster
110 |
111 | ```sh
112 | $ builder run check-dev
113 | ```
114 |
115 | Command. It is comprised of:
116 |
117 | ```sh
118 | $ builder run lint
119 | $ builder run test-dev
120 | ```
121 |
122 | Note that the tests here are not instrumented for code coverage and are thus
123 | more development / debugging friendly.
124 |
125 | ### Continuous Integration
126 |
127 | CI doesn't have source / test file watchers, so has to _build_ the test files
128 | via the commands:
129 |
130 | ```sh
131 | $ builder run check # PhantomJS only
132 | $ builder run check-cov # (OR) PhantomJS w/ coverage
133 | $ builder run check-ci # (OR) PhantomJS,Firefox + coverage - available on Travis.
134 | ```
135 |
136 | Which is currently comprised of:
137 |
138 | ```sh
139 | $ builder run lint # AND ...
140 |
141 | $ builder run test # PhantomJS only
142 | $ builder run test-cov # (OR) PhantomJS w/ coverage
143 | $ builder run test-ci # (OR) PhantomJS,Firefox + coverage
144 | ```
145 |
146 | Note that `(test|check)-(cov|ci)` run code coverage and thus the
147 | test code may be harder to debug because it is instrumented.
148 |
149 | ### Client Tests
150 |
151 | The client tests rely on webpack dev server to create and serve the bundle
152 | of the app/test code at: http://127.0.0.1:3001/assets/main.js which is done
153 | with the task `builder run server-test` (part of `npm dev`).
154 |
155 | #### Code Coverage
156 |
157 | Code coverage reports are outputted to:
158 |
159 | ```
160 | coverage/
161 | client/
162 | BROWSER_STRING/
163 | lcov-report/index.html # Viewable web report.
164 | ```
165 |
166 | ## Releases
167 |
168 | **IMPORTANT - NPM**: To correctly run `preversion` your first step is to make
169 | sure that you have a very modern `npm` binary:
170 |
171 | ```sh
172 | $ npm install -g npm
173 | ```
174 |
175 | Built files in `dist/` should **not** be committeed during development or PRs.
176 | Instead we _only_ build and commit them for published, tagged releases. So
177 | the basic workflow is:
178 |
179 | ```sh
180 | # Make sure you have a clean, up-to-date `master`
181 | $ git pull
182 | $ git status # (should be no changes)
183 |
184 | # Choose a semantic update for the new version.
185 | # If you're unsure, read about semantic versioning at http://semver.org/
186 | $ npm version major|minor|patch -m "Version %s - INSERT_REASONS"
187 |
188 | # ... the `dist/` and `lib/` directories are now built, `package.json` is
189 | # updated, and the appropriate files are committed to git (but unpushed).
190 | #
191 | # *Note*: `lib/` is uncommitted, but built and must be present to push to npm.
192 |
193 | # Check that everything looks good in last commit and push.
194 | $ git diff HEAD^ HEAD
195 | $ git push && git push --tags
196 | # ... the project is now pushed to GitHub and available to `bower`.
197 |
198 | # And finally publish to `npm`!
199 | $ npm publish
200 | ```
201 |
202 | And you've published!
203 |
204 | For additional information on the underlying NPM technologies and approaches,
205 | please review:
206 |
207 | * [`npm version`](https://docs.npmjs.com/cli/version): Runs verification,
208 | builds `dist/` and `lib/` via `scripts` commands.
209 | * Our scripts also run the applicable `git` commands, so be very careful
210 | when running out `version` commands.
211 | * [`npm publish`](https://docs.npmjs.com/cli/publish): Uploads to NPM.
212 | * **NOTE**: We don't _build_ in `prepublish` because of the
213 | [`npm install` runs `npm prepublish` bug](https://github.com/npm/npm/issues/3059)
214 |
215 | [builder]: https://github.com/FormidableLabs/builder
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Formidable Labs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![Travis Status][trav_img]][trav_site]
2 |
3 | React Component Boilerplate
4 | ===========================
5 |
6 | Formidable Labs flavored React component boilerplate. This is a set of opinions
7 | on how to start a React component.
8 |
9 | ## The Generator
10 |
11 | We expect these opinions to change *often*. We've written a yeoman generator to
12 | pull down the freshest copy of this repo whenever you use it. It just copies
13 | this repo so you don't have to. Check it out
14 | [here](https://github.com/FormidableLabs/generator-formidable-react-component)
15 |
16 | To create a new project based on this boilerplate:
17 |
18 | ```sh
19 | $ npm install -g yo
20 | $ npm install -g generator-formidable-react-component
21 | $ yo formidable-react-component
22 | ```
23 |
24 | The generator replaces `formidable-react-component-boilerplate` and
25 | `FormidableReactComponentBoilerplate` across this repo with names specific to
26 | your new project. `src/components/formidable-react-component-boilerplate.jsx`
27 | and `test/client/spec/components/formidable-react-component-boilerplate.spec.jsx`
28 | are also renamed, and a fresh `README.md` is created.
29 |
30 | ## Development
31 |
32 | Please see [DEVELOPMENT](DEVELOPMENT.md)
33 |
34 | ## Contributing
35 |
36 | Please see [CONTRIBUTING](CONTRIBUTING.md)
37 |
38 | [trav_img]: https://api.travis-ci.org/FormidableLabs/formidable-react-component-boilerplate.svg
39 | [trav_site]: https://travis-ci.org/FormidableLabs/formidable-react-component-boilerplate
40 |
--------------------------------------------------------------------------------
/demo/app.jsx:
--------------------------------------------------------------------------------
1 | /*global document:false*/
2 | import React from "react";
3 | import ReactDOM from "react-dom";
4 | import {FormidableReactComponentBoilerplate} from "../src/index";
5 |
6 | class App extends React.Component {
7 | render() {
8 | return (
9 |