├── .codeclimate.yml ├── .editorconfig ├── .env.example ├── .eslintignore ├── .eslintrc ├── .flowconfig ├── .gitignore ├── .lintstagedrc ├── .nvmrc ├── .stylelintignore ├── .stylelintrc ├── .travis.yml ├── .yarnclean ├── LICENSE ├── README.md ├── config ├── env.js ├── jest │ ├── cssTransform.js │ └── fileTransform.js ├── paths.js ├── polyfills.js ├── webpack.config.dev.js ├── webpack.config.prod.js └── webpackDevServer.config.js ├── decls └── lodashFlow.js ├── docs ├── 01-coding-conventions.md ├── 02-best-pratices.md ├── 03-tools.md ├── 04-create-react-app.md └── README.md ├── flow-typed └── npm │ ├── autoprefixer_vx.x.x.js │ ├── babel-core_vx.x.x.js │ ├── babel-eslint_vx.x.x.js │ ├── babel-jest_vx.x.x.js │ ├── babel-loader_vx.x.x.js │ ├── babel-plugin-transform-decorators-legacy_vx.x.x.js │ ├── babel-preset-react-app_vx.x.x.js │ ├── babel-runtime_vx.x.x.js │ ├── case-sensitive-paths-webpack-plugin_vx.x.x.js │ ├── chalk_v1.x.x.js │ ├── css-loader_vx.x.x.js │ ├── dotenv_vx.x.x.js │ ├── eslint-config-react-app_vx.x.x.js │ ├── eslint-loader_vx.x.x.js │ ├── eslint-plugin-flowtype_vx.x.x.js │ ├── eslint-plugin-import_vx.x.x.js │ ├── eslint-plugin-jsx-a11y_vx.x.x.js │ ├── eslint-plugin-react_vx.x.x.js │ ├── eslint_vx.x.x.js │ ├── extract-text-webpack-plugin_vx.x.x.js │ ├── file-loader_vx.x.x.js │ ├── flow-bin_v0.x.x.js │ ├── flow-typed_vx.x.x.js │ ├── fs-extra_vx.x.x.js │ ├── html-webpack-plugin_vx.x.x.js │ ├── husky_vx.x.x.js │ ├── jest_v20.x.x.js │ ├── lint-staged_vx.x.x.js │ ├── mobx-react_vx.x.x.js │ ├── normalize.css_vx.x.x.js │ ├── npm-run-all_vx.x.x.js │ ├── object-assign_v4.x.x.js │ ├── postcss-flexbugs-fixes_vx.x.x.js │ ├── postcss-loader_vx.x.x.js │ ├── prettier-eslint-cli_vx.x.x.js │ ├── react-dev-utils_vx.x.x.js │ ├── react-hot-loader_vx.x.x.js │ ├── react-router-dom_v4.x.x.js │ ├── react-test-renderer_vx.x.x.js │ ├── style-loader_vx.x.x.js │ ├── stylefmt_vx.x.x.js │ ├── stylelint-config-standard_vx.x.x.js │ ├── stylelint_vx.x.x.js │ ├── sw-precache-webpack-plugin_vx.x.x.js │ ├── url-loader_vx.x.x.js │ ├── webpack-dev-server_vx.x.x.js │ ├── webpack-manifest-plugin_vx.x.x.js │ ├── webpack_vx.x.x.js │ └── whatwg-fetch_vx.x.x.js ├── package.json ├── public ├── favicon.ico └── index.html ├── scripts ├── build.js ├── start.js └── test.js ├── src ├── hello │ ├── components │ │ ├── Hello.css │ │ ├── Hello.js │ │ ├── Hello.test.js │ │ └── __snapshots__ │ │ │ └── Hello.test.js.snap │ └── store.js ├── index.css ├── index.js ├── logo.svg ├── root │ └── components │ │ ├── Root.css │ │ ├── Root.js │ │ └── Root.test.js └── styles │ ├── colors.css │ └── typography.css └── yarn.lock /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | engines: 3 | csslint: 4 | enabled: true 5 | duplication: 6 | enabled: true 7 | config: 8 | languages: 9 | - javascript 10 | eslint: 11 | enabled: true 12 | channel: "eslint-3" 13 | fixme: 14 | enabled: true 15 | ratings: 16 | paths: 17 | - "**.css" 18 | - "**.js" 19 | exclude_paths: 20 | - build 21 | - config 22 | - decls 23 | - flow-typed 24 | - scripts 25 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | indent_size = 2 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.md] 14 | indent_size = 4 -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | REACT_APP_TITLE=React Boilerplate 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /build 2 | /config 3 | /scripts 4 | /flow-typed 5 | /decls 6 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "react-app", 4 | "plugin:flowtype/recommended" 5 | ], 6 | "rules": { 7 | "comma-dangle": [2, "always-multiline"], 8 | "eol-last": [2, "always"], 9 | "indent": [2, 2, {"SwitchCase":1}], 10 | "quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}], 11 | "object-curly-spacing": [2, "never"], 12 | "semi": [2, "never"], 13 | "space-infix-ops": "error" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ./decls 3 | .*/node_modules/stylelint/lib 4 | 5 | [include] 6 | ./src 7 | 8 | [libs] 9 | flow-typed/ 10 | ./node_modules/stylelint/decls 11 | decls/ 12 | 13 | [options] 14 | module.name_mapper.extension='css' -> 'CSSModule' 15 | module.name_mapper.extension='svg' -> 'EmptyModule' 16 | 17 | esproposal.decorators=ignore 18 | 19 | ; Consider $FlowFixMe as @todo for type issues 20 | suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe 21 | ; In cases where a type error comes out of a bug in flow 22 | suppress_comment= \\(.\\|\n\\)*\\$FlowIssue 23 | ; Type errors that we just ignore and won't try to fix in the future 24 | suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore 25 | ; For writing expected errors in type tests 26 | suppress_comment= \\(.\\|\n\\)*\\$FlowExpectError 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # ide 4 | /.idea 5 | 6 | # dependencies 7 | /node_modules 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build 14 | 15 | # misc 16 | .DS_Store 17 | .env 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "*.js": [ 3 | "prettier-eslint --write \"src/**/*.js\"", 4 | "git add" 5 | ], 6 | "*.css": [ 7 | "stylefmt", 8 | "git add" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 8.9 2 | -------------------------------------------------------------------------------- /.stylelintignore: -------------------------------------------------------------------------------- 1 | /build 2 | /config 3 | /scripts 4 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-standard", 3 | "rules": { 4 | "at-rule-no-vendor-prefix": true, 5 | "declaration-empty-line-before": null, 6 | "font-family-name-quotes": "always-where-recommended", 7 | "function-url-quotes": "never", 8 | "string-quotes": "single", 9 | "selector-pseudo-class-no-unknown": [true, { 10 | "ignorePseudoClasses": ["global", "root"] 11 | }], 12 | 'property-no-unknown': [true, { 13 | ignoreProperties: ['composes'], 14 | }], 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | # Use container-based infrastructure 4 | sudo: false 5 | 6 | node_js: 7 | - "node" # latest stable Node.js release 8 | - "7" 9 | - "6" 10 | 11 | install: 12 | - yarn global add codeclimate-test-reporter 13 | - yarn --frozen-lockfile 14 | 15 | script: 16 | - yarn run ci 17 | 18 | after_script: 19 | - codeclimate-test-reporter < coverage/lcov.info 20 | 21 | addons: 22 | code_climate: 23 | repo_token: 7769d83c32de97e4b4d5df87c0520dbe930fb43fff3ab8160e87149ea8fb7335 24 | -------------------------------------------------------------------------------- /.yarnclean: -------------------------------------------------------------------------------- 1 | # test directories 2 | __tests__ 3 | test 4 | tests 5 | powered-test 6 | 7 | # asset directories 8 | docs 9 | doc 10 | website 11 | images 12 | assets 13 | 14 | # examples 15 | example 16 | examples 17 | 18 | # code coverage directories 19 | coverage 20 | .nyc_output 21 | 22 | # build scripts 23 | Makefile 24 | Gulpfile.js 25 | Gruntfile.js 26 | 27 | # configs 28 | .tern-project 29 | .gitattributes 30 | .editorconfig 31 | .*ignore 32 | .eslintrc 33 | .jshintrc 34 | .flowconfig 35 | .documentup.json 36 | .yarn-metadata.json 37 | 38 | # misc 39 | *.gz 40 | *.md 41 | 42 | # Don't clean files needed for code coverage report 43 | !istanbul-reports/lib/html/assets 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Digia Oyj 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 | # React Boilerplate (deprecated) 2 | 3 | ## This project is deprecated. Please use [Create React App](https://github.com/facebook/create-react-app) to bootstrap your React projects. 4 | 5 | [![Build Status](https://travis-ci.org/digiaonline/react-boilerplate.svg?branch=master)](https://travis-ci.org/digiaonline/react-boilerplate) 6 | [![Test Coverage](https://lima.codeclimate.com/github/digiaonline/react-boilerplate/badges/coverage.svg)](https://lima.codeclimate.com/github/digiaonline/react-boilerplate/coverage) 7 | [![Code Climate](https://codeclimate.com/github/digiaonline/react-boilerplate/badges/gpa.svg)](https://codeclimate.com/github/digiaonline/react-boilerplate) 8 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 9 | 10 | A [Digia](https://github.com/digiaonline/) project. 11 | 12 | ## Why do I want this? 13 | 14 | As you probably know, there are numerous boilerplates available for [React](https://facebook.github.io/react/), so you might be wondering why you would want to use ours. Most of the boilerplate projects come with a lot of code that you rarely need. Our boilerplate was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app) and provides you with a great starting point for any React project with as few lines of code as possible, especially if you want to use [Flowtype](https://flowtype.org/). 15 | 16 | ## What do I need to get started? 17 | 18 | - [Node](https://nodejs.org/en/download/) (version 6 or later) 19 | - [Yarn](https://yarnpkg.com/lang/en/docs/install/) 20 | 21 | ## What's in the box? 22 | 23 | - [Flowtype](https://flowtype.org/) Type checker 24 | - [React](https://facebook.github.io/react/) User interface components 25 | - [MobX](https://mobx.js.org/) Simple, scalable state management 26 | - [Lodash](https://lodash.com/) Utility library 27 | - [Babel](https://babeljs.io/) JavaScript transpiler 28 | - [ESLint](http://eslint.org/) JavaScript Linter 29 | - [Prettier](https://github.com/prettier/prettier) Code formatter 30 | - [PostCSS](http://postcss.org/) CSS transformer 31 | - [Stylelint](https://stylelint.io/) CSS Linter 32 | - [Webpack](https://webpack.js.org/) Module bundler 33 | - [Jest](https://facebook.github.io/jest/) Testing solution 34 | 35 | ## How do I use this? 36 | 37 | You can find our documentation [here](./docs/README.md). 38 | 39 | ## Usage 40 | 41 | ### Create project 42 | 43 | Install [create-project](https://www.npmjs.com/package/create-project) and create your project. 44 | 45 | ```bash 46 | yarn global add create-project 47 | create-project my-project digiaonline/react-boilerplate && cd my-project 48 | ``` 49 | 50 | ### Install dependencies 51 | 52 | Install the project dependencies using Yarn. 53 | 54 | ```bash 55 | yarn 56 | ``` 57 | 58 | ### Create the environment 59 | 60 | Create your environment by copying the example environment. 61 | 62 | ```bash 63 | cp .env.example .env 64 | ``` 65 | 66 | ### Development server 67 | 68 | You can start the development server with the `start` script. 69 | 70 | ```bash 71 | yarn start 72 | ``` 73 | 74 | ### Distribution build 75 | 76 | You can compile the distribution build with the `build` script. 77 | 78 | ```bash 79 | yarn build 80 | ``` 81 | ## Test 82 | 83 | ### Test suite 84 | 85 | You can run the test suite with the `test` script. 86 | 87 | ```bash 88 | yarn test 89 | ``` 90 | 91 | ## License 92 | 93 | [MIT](LICENSE) 94 | -------------------------------------------------------------------------------- /config/env.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const paths = require('./paths'); 6 | 7 | // Make sure that including paths.js after env.js will read .env variables. 8 | delete require.cache[require.resolve('./paths')]; 9 | 10 | const NODE_ENV = process.env.NODE_ENV; 11 | if (!NODE_ENV) { 12 | throw new Error( 13 | 'The NODE_ENV environment variable is required but was not specified.' 14 | ); 15 | } 16 | 17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use 18 | var dotenvFiles = [ 19 | `${paths.dotenv}.${NODE_ENV}.local`, 20 | `${paths.dotenv}.${NODE_ENV}`, 21 | // Don't include `.env.local` for `test` environment 22 | // since normally you expect tests to produce the same 23 | // results for everyone 24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`, 25 | paths.dotenv, 26 | ].filter(Boolean); 27 | 28 | // Load environment variables from .env* files. Suppress warnings using silent 29 | // if this file is missing. dotenv will never modify any environment variables 30 | // that have already been set. 31 | // https://github.com/motdotla/dotenv 32 | dotenvFiles.forEach(dotenvFile => { 33 | if (fs.existsSync(dotenvFile)) { 34 | require('dotenv').config({ 35 | path: dotenvFile, 36 | }); 37 | } 38 | }); 39 | 40 | // We support resolving modules according to `NODE_PATH`. 41 | // This lets you use absolute paths in imports inside large monorepos: 42 | // https://github.com/facebookincubator/create-react-app/issues/253. 43 | // It works similar to `NODE_PATH` in Node itself: 44 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders 45 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. 46 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. 47 | // https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 48 | // We also resolve them to make sure all tools using them work consistently. 49 | const appDirectory = fs.realpathSync(process.cwd()); 50 | process.env.NODE_PATH = (process.env.NODE_PATH || '') 51 | .split(path.delimiter) 52 | .filter(folder => folder && !path.isAbsolute(folder)) 53 | .map(folder => path.resolve(appDirectory, folder)) 54 | .join(path.delimiter); 55 | 56 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be 57 | // injected into the application via DefinePlugin in Webpack configuration. 58 | const REACT_APP = /^REACT_APP_/i; 59 | 60 | function getClientEnvironment(publicUrl) { 61 | const raw = Object.keys(process.env) 62 | .filter(key => REACT_APP.test(key)) 63 | .reduce( 64 | (env, key) => { 65 | env[key] = process.env[key]; 66 | return env; 67 | }, 68 | { 69 | // Useful for determining whether we’re running in production mode. 70 | // Most importantly, it switches React into the correct mode. 71 | NODE_ENV: process.env.NODE_ENV || 'development', 72 | // Useful for resolving the correct path to static assets in `public`. 73 | // For example, . 74 | // This should only be used as an escape hatch. Normally you would put 75 | // images into the `src` and `import` them in code to get their paths. 76 | PUBLIC_URL: publicUrl, 77 | } 78 | ); 79 | // Stringify all values so we can feed into Webpack DefinePlugin 80 | const stringified = { 81 | 'process.env': Object.keys(raw).reduce((env, key) => { 82 | env[key] = JSON.stringify(raw[key]); 83 | return env; 84 | }, {}), 85 | }; 86 | 87 | return { raw, stringified }; 88 | } 89 | 90 | module.exports = getClientEnvironment; 91 | -------------------------------------------------------------------------------- /config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This is a custom Jest transformer turning style imports into empty objects. 4 | // http://facebook.github.io/jest/docs/tutorial-webpack.html 5 | 6 | module.exports = { 7 | process() { 8 | return 'module.exports = {};'; 9 | }, 10 | getCacheKey() { 11 | // The output is always the same. 12 | return 'cssTransform'; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | // This is a custom Jest transformer turning file imports into filenames. 6 | // http://facebook.github.io/jest/docs/tutorial-webpack.html 7 | 8 | module.exports = { 9 | process(src, filename) { 10 | return `module.exports = ${JSON.stringify(path.basename(filename))};`; 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /config/paths.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const fs = require('fs'); 5 | const url = require('url'); 6 | 7 | // Make sure any symlinks in the project folder are resolved: 8 | // https://github.com/facebookincubator/create-react-app/issues/637 9 | const appDirectory = fs.realpathSync(process.cwd()); 10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath); 11 | 12 | const envPublicUrl = process.env.PUBLIC_URL; 13 | 14 | function ensureSlash(path, needsSlash) { 15 | const hasSlash = path.endsWith('/'); 16 | if (hasSlash && !needsSlash) { 17 | return path.substr(path, path.length - 1); 18 | } else if (!hasSlash && needsSlash) { 19 | return `${path}/`; 20 | } else { 21 | return path; 22 | } 23 | } 24 | 25 | const getPublicUrl = appPackageJson => 26 | envPublicUrl || require(appPackageJson).homepage; 27 | 28 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer 29 | // "public path" at which the app is served. 30 | // Webpack needs to know it to put the right