Skip to content

Commit fc40fb1

Browse files
authored
Merge pull request #6 from corgicode/feature/5-css
Closes #5 added css files to project
2 parents 7e7b82a + 42e27cb commit fc40fb1

File tree

99 files changed

+18916
-1686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+18916
-1686
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build
2+
node_modules
3+
coverage
4+
webpack.*.js
5+
*server.js

.eslintrc

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
{
2+
"parser": "babel-eslint", // https://github.com/babel/babel-eslint
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"mocha": true,
7+
"jest": true
8+
},
9+
"globals": {
10+
"expect": true,
11+
"sinon": true,
12+
"__DEV__": true
13+
},
14+
"rules": {
15+
"no-var": 2, // http://eslint.org/docs/rules/no-var
16+
"prefer-const": 2, // http://eslint.org/docs/rules/prefer-const
17+
18+
/**
19+
* Variables
20+
*/
21+
"no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
22+
"no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
23+
"no-undef": 2, // http://eslint.org/docs/rules/no-undef
24+
"no-unused-vars": [2, { // http://eslint.org/docs/rules/no-unused-vars
25+
"vars": "local",
26+
"args": "after-used"
27+
}],
28+
"no-use-before-define": 2, // http://eslint.org/docs/rules/no-use-before-define
29+
30+
/**
31+
* Possible errors
32+
*/
33+
"no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign
34+
"no-console": 0, // http://eslint.org/docs/rules/no-console
35+
"no-debugger": 1, // http://eslint.org/docs/rules/no-debugger
36+
"no-alert": 1, // http://eslint.org/docs/rules/no-alert
37+
"no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition
38+
"no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
39+
"no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
40+
"no-empty": 2, // http://eslint.org/docs/rules/no-empty
41+
"no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
42+
"no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
43+
"no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi
44+
"no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign
45+
"no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations
46+
"no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp
47+
"no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace
48+
"no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls
49+
"no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays
50+
"no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
51+
"use-isnan": 2, // http://eslint.org/docs/rules/use-isnan
52+
"block-scoped-var": 2, // http://eslint.org/docs/rules/block-scoped-var
53+
54+
/**
55+
* Best practices
56+
*/
57+
"consistent-return": 2, // http://eslint.org/docs/rules/consistent-return
58+
"curly": [2, "multi-line"], // http://eslint.org/docs/rules/curly
59+
"default-case": 2, // http://eslint.org/docs/rules/default-case
60+
"dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation
61+
"allowKeywords": true
62+
}],
63+
"eqeqeq": 2, // http://eslint.org/docs/rules/eqeqeq
64+
"guard-for-in": 2, // http://eslint.org/docs/rules/guard-for-in
65+
"no-caller": 2, // http://eslint.org/docs/rules/no-caller
66+
"no-else-return": 2, // http://eslint.org/docs/rules/no-else-return
67+
"no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null
68+
"no-eval": 2, // http://eslint.org/docs/rules/no-eval
69+
"no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native
70+
"no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind
71+
"no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough
72+
"no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal
73+
"no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval
74+
"no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks
75+
"no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func
76+
"no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str
77+
"no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign
78+
"no-new": 2, // http://eslint.org/docs/rules/no-new
79+
"no-new-func": 2, // http://eslint.org/docs/rules/no-new-func
80+
"no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers
81+
"no-octal": 2, // http://eslint.org/docs/rules/no-octal
82+
"no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape
83+
"no-param-reassign": 2, // http://eslint.org/docs/rules/no-param-reassign
84+
"no-proto": 2, // http://eslint.org/docs/rules/no-proto
85+
"no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare
86+
"no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign
87+
"no-script-url": 2, // http://eslint.org/docs/rules/no-script-url
88+
"no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare
89+
"no-sequences": 2, // http://eslint.org/docs/rules/no-sequences
90+
"no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal
91+
"no-with": 2, // http://eslint.org/docs/rules/no-with
92+
"radix": 2, // http://eslint.org/docs/rules/radix
93+
"vars-on-top": 2, // http://eslint.org/docs/rules/vars-on-top
94+
"yoda": 2, // http://eslint.org/docs/rules/yoda
95+
96+
/**
97+
* Style
98+
*/
99+
"indent": [
100+
2,
101+
4,
102+
{ "SwitchCase": 1 }
103+
], // http://eslint.org/docs/rules/indent
104+
"brace-style": [
105+
2,
106+
"1tbs", {
107+
"allowSingleLine": true
108+
}
109+
], // http://eslint.org/docs/rules/brace-style
110+
"quotes": [
111+
2, "single", "avoid-escape" // http://eslint.org/docs/rules/quotes
112+
],
113+
"camelcase": [2, { // http://eslint.org/docs/rules/camelcase
114+
"properties": "never"
115+
}],
116+
"comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing
117+
"before": false,
118+
"after": true
119+
}],
120+
"comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style
121+
"eol-last": 2, // http://eslint.org/docs/rules/eol-last
122+
"func-names": 1, // http://eslint.org/docs/rules/func-names
123+
"key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing
124+
"beforeColon": false,
125+
"afterColon": true
126+
}],
127+
"new-cap": [0, { // http://eslint.org/docs/rules/new-cap
128+
"newIsCap": true
129+
}],
130+
"no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
131+
"max": 2
132+
}],
133+
"no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary
134+
"no-new-object": 2, // http://eslint.org/docs/rules/no-new-object
135+
"no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func
136+
"no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces
137+
"no-extra-parens": [2, "functions"], // http://eslint.org/docs/rules/no-extra-parens
138+
"no-underscore-dangle": 0, // http://eslint.org/docs/rules/no-underscore-dangle
139+
"one-var": [2, "never"], // http://eslint.org/docs/rules/one-var
140+
"padded-blocks": [2, "never"], // http://eslint.org/docs/rules/padded-blocks
141+
"semi": [2, "always"], // http://eslint.org/docs/rules/semi
142+
"semi-spacing": [2, { // http://eslint.org/docs/rules/semi-spacing
143+
"before": false,
144+
"after": true
145+
}],
146+
"space-before-blocks": 2, // http://eslint.org/docs/rules/space-before-blocks
147+
"space-before-function-paren": [2, "never"], // http://eslint.org/docs/rules/space-before-function-paren
148+
"space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops
149+
"spaced-comment": [2, "always", {// http://eslint.org/docs/rules/spaced-comment
150+
"exceptions": ["-", "+"],
151+
"markers": ["=", "!"] // space here to support sprockets directives
152+
}],
153+
// React
154+
"jsx-quotes": [2, "prefer-double"],
155+
"react/display-name": 0,
156+
"react/jsx-boolean-value": 1,
157+
"react/jsx-no-undef": 2,
158+
"react/jsx-sort-prop-types": 0,
159+
"react/jsx-sort-props": 0,
160+
"react/jsx-uses-react": 1,
161+
"react/jsx-uses-vars": 1,
162+
"react/no-did-mount-set-state": [2],
163+
"react/no-did-update-set-state": 2,
164+
"react/no-multi-comp": 2,
165+
"react/no-unknown-property": 2,
166+
"react/prop-types": 2,
167+
"react/react-in-jsx-scope": 2,
168+
"react/self-closing-comp": 2,
169+
"react/sort-comp": 2,
170+
"react/jsx-wrap-multilines": 2
171+
},
172+
"plugins": [
173+
"react"
174+
]
175+
}

config/env.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
const 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, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
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;

config/jest/cssTransform.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
};

config/jest/fileTransform.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
};

config/paths.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
}
21+
return _path;
22+
}
23+
24+
const getPublicUrl = appPackageJson =>
25+
envPublicUrl || require(appPackageJson).homepage;
26+
27+
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
28+
// "public path" at which the app is served.
29+
// Webpack needs to know it to put the right <script> hrefs into HTML even in
30+
// single-page apps that may serve index.html for nested URLs like /todos/42.
31+
// We can't use a relative path in HTML because we don't want to load something
32+
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
33+
function getServedPath(appPackageJson) {
34+
const publicUrl = getPublicUrl(appPackageJson);
35+
const servedUrl =
36+
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
37+
return ensureSlash(servedUrl, true);
38+
}
39+
40+
// config after eject: we're in ./config/
41+
module.exports = {
42+
dotenv: resolveApp('.env'),
43+
appBuild: resolveApp('build'),
44+
appPublic: resolveApp('public'),
45+
appHtml: resolveApp('public/index.html'),
46+
appIndexJs: resolveApp('src/index.js'),
47+
appPackageJson: resolveApp('package.json'),
48+
appSrc: resolveApp('src'),
49+
yarnLockFile: resolveApp('yarn.lock'),
50+
testsSetup: resolveApp('src/setupTests.js'),
51+
appNodeModules: resolveApp('node_modules'),
52+
publicUrl: getPublicUrl(resolveApp('package.json')),
53+
servedPath: getServedPath(resolveApp('package.json')),
54+
};

config/polyfills.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
if (typeof Promise === 'undefined') {
4+
// Rejection tracking prevents a common issue where React gets into an
5+
// inconsistent state due to an error, but it gets swallowed by a Promise,
6+
// and the user has no idea what causes React's erratic future behavior.
7+
require('promise/lib/rejection-tracking').enable();
8+
window.Promise = require('promise/lib/es6-extensions.js');
9+
}
10+
11+
// fetch() polyfill for making API calls.
12+
require('whatwg-fetch');
13+
14+
// Object.assign() is commonly used with React.
15+
// It will use the native implementation if it's present and isn't buggy.
16+
Object.assign = require('object-assign');
17+
18+
// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
19+
// We don't polyfill it in the browser--this is user's responsibility.
20+
if (process.env.NODE_ENV === 'test') {
21+
require('raf').polyfill(global);
22+
}

0 commit comments

Comments
 (0)