Skip to content

Commit 3718834

Browse files
committedAug 22, 2018
fix linting
1 parent 58b13c5 commit 3718834

16 files changed

+115
-101
lines changed
 

‎.eslintrc.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"no-use-before-define": 0,
1313
"react/jsx-filename-extension": 0,
1414
"react/prop-types": 0,
15-
"react/destructuring-assignment": 0
15+
"react/destructuring-assignment": 0,
16+
"no-shadow": 0,
17+
"global-require": 0,
18+
"import/no-dynamic-require": 0
1619
}
1720
}

‎README.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🚦 Code Coverage Dashboard
22

3-
A simple dashboard for Istanbul code coverage reports designed to be deployed to Heroku. The app takes any `coverage-summary.json` input file hosted within a folder on github and displays the data in a set of easily configurable chart components. Works great for a dev team to see their code coverage improving over time.
3+
A simple dashboard for [Istanbul](https://github.com/gotwarlost/istanbul) code coverage reports designed to be deployed to Heroku. The app takes any `coverage-summary.json` input file hosted within a folder on github and displays the data in a set of easily configurable chart components. Works great for a dev team to see their code coverage improving over time.
44

55
![Code cov dash](https://raw.githubusercontent.com/ezy/code-coverage-dashboard/master/public/code-cov-dash.png)
66

@@ -34,32 +34,42 @@ Reports are generated from the `json-summary` report by Istanbul. There's an exa
3434

3535
## Configuring reports
3636

37-
There are three different report charts that are displayed: A dateTime based line chart displaying total statement coverage; a summary of total coverage values as donut charts; and a group of stack charts that display coverage for individual and grouped report strings.
37+
There are three different report charts that are displayed: A dateTime based **line chart** displaying total statement coverage; a summary of total coverage values as **donut charts**; and a group of **stack charts** that display coverage for individual and grouped report strings.
3838

3939
### Line chart
4040

4141
The line chart component is located at `src/components/LineChart.js`. It takes an array of values from `localStorage` and displays them as date (X axis) and value (Y axis) from the object input: `{value: 96.75, date: "2018-08-21T04:13:07.414Z"}`. All localStorage values are loaded in the `src/templates/App.js` file.
4242

4343
### Donut chart
4444

45+
The donut chart is fixed and takes the JSON fetched from `coverage-summary.json` as `data` props. It's currently hard-coded to display the percentage of the report totals with the `selectName` property for the corresponding nested key in the `total` object.
46+
47+
eg. `<DonutChart selectName="statements" data={this.state.data} />`
48+
49+
### Stack chart
50+
51+
The stack charts take the JSON fetched from `coverage-summary.json` as `data` props. They take a second property `fileSet` that can be specified as all or part of the object key strings in `coverage-summary.json`. The stack chart will display the average coverage for an keys that match the `fileSet` property.
52+
53+
eg. `<StackChart fileSet="server/user" data={this.state.data} />`
54+
4555
## Available scripts
4656

4757
In the project directory, you can run:
4858

49-
### `npm start`
59+
### `yarn start`
5060

5161
Runs the app in the development mode.<br>
5262
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
5363

5464
The page will reload if you make edits.<br>
5565
You will also see any lint errors in the console.
5666

57-
### `npm test`
67+
### `yarn test`
5868

5969
Launches the test runner in the interactive watch mode.<br>
6070
See the section about [running tests](#running-tests) for more information.
6171

62-
### `npm run build`
72+
### `yarn build`
6373

6474
Builds the app for production to the `build` folder.<br>
6575
It correctly bundles React in production mode and optimizes the build for the best performance.
@@ -68,5 +78,3 @@ The build is minified and the filenames include the hashes.<br>
6878
Your app is ready to be deployed!
6979

7080
See the section about [deployment](#deployment) for more information.
71-
72-
## Supported browsers

‎config/env.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
'use strict';
2-
31
const fs = require('fs');
42
const path = require('path');
53
const paths = require('./paths');
64

75
// Make sure that including paths.js after env.js will read .env variables.
86
delete require.cache[require.resolve('./paths')];
97

10-
const NODE_ENV = process.env.NODE_ENV;
8+
const { NODE_ENV } = process.env;
119
if (!NODE_ENV) {
1210
throw new Error(
13-
'The NODE_ENV environment variable is required but was not specified.'
11+
'The NODE_ENV environment variable is required but was not specified.',
1412
);
1513
}
1614

1715
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18-
var dotenvFiles = [
16+
const dotenvFiles = [
1917
`${paths.dotenv}.${NODE_ENV}.local`,
2018
`${paths.dotenv}.${NODE_ENV}`,
2119
// Don't include `.env.local` for `test` environment
@@ -30,12 +28,12 @@ var dotenvFiles = [
3028
// that have already been set. Variable expansion is supported in .env files.
3129
// https://github.com/motdotla/dotenv
3230
// https://github.com/motdotla/dotenv-expand
33-
dotenvFiles.forEach(dotenvFile => {
31+
dotenvFiles.forEach((dotenvFile) => {
3432
if (fs.existsSync(dotenvFile)) {
3533
require('dotenv-expand')(
3634
require('dotenv').config({
3735
path: dotenvFile,
38-
})
36+
}),
3937
);
4038
}
4139
});
@@ -76,8 +74,8 @@ function getClientEnvironment(publicUrl) {
7674
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
7775
// This should only be used as an escape hatch. Normally you would put
7876
// images into the `src` and `import` them in code to get their paths.
79-
PUBLIC_URL: publicUrl
80-
}
77+
PUBLIC_URL: publicUrl,
78+
},
8179
);
8280
// Stringify all values so we can feed into Webpack DefinePlugin
8381
const stringified = {

‎config/jest/cssTransform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
// This is a custom Jest transformer turning style imports into empty objects.
44
// http://facebook.github.io/jest/docs/en/webpack.html

‎config/jest/fileTransform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
const path = require('path');
44

‎config/paths.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
const path = require('path');
44
const fs = require('fs');
@@ -15,15 +15,13 @@ function ensureSlash(path, needsSlash) {
1515
const hasSlash = path.endsWith('/');
1616
if (hasSlash && !needsSlash) {
1717
return path.substr(path, path.length - 1);
18-
} else if (!hasSlash && needsSlash) {
18+
} if (!hasSlash && needsSlash) {
1919
return `${path}/`;
20-
} else {
21-
return path;
2220
}
21+
return path;
2322
}
2423

25-
const getPublicUrl = appPackageJson =>
26-
envPublicUrl || require(appPackageJson).homepage;
24+
const getPublicUrl = appPackageJson => envPublicUrl || require(appPackageJson).homepage;
2725

2826
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
2927
// "public path" at which the app is served.
@@ -33,8 +31,7 @@ const getPublicUrl = appPackageJson =>
3331
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
3432
function getServedPath(appPackageJson) {
3533
const publicUrl = getPublicUrl(appPackageJson);
36-
const servedUrl =
37-
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
34+
const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
3835
return ensureSlash(servedUrl, true);
3936
}
4037

‎config/polyfills.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
if (typeof Promise === 'undefined') {
44
// Rejection tracking prevents a common issue where React gets into an

‎config/webpack.config.dev.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
const autoprefixer = require('autoprefixer');
44
const path = require('path');
@@ -62,10 +62,9 @@ module.exports = {
6262
// There are also additional JS chunk files if you use code splitting.
6363
chunkFilename: 'static/js/[name].chunk.js',
6464
// This is the URL that app is served from. We use "/" in development.
65-
publicPath: publicPath,
65+
publicPath,
6666
// Point sourcemap entries to original disk location (format as URL on Windows)
67-
devtoolModuleFilenameTemplate: info =>
68-
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
67+
devtoolModuleFilenameTemplate: info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
6968
},
7069
resolve: {
7170
// This allows you to set a fallback for where Webpack should look for modules.
@@ -74,7 +73,7 @@ module.exports = {
7473
// https://github.com/facebookincubator/create-react-app/issues/253
7574
modules: ['node_modules', paths.appNodeModules].concat(
7675
// It is guaranteed to exist because we tweak it in `env.js`
77-
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
76+
process.env.NODE_PATH.split(path.delimiter).filter(Boolean),
7877
),
7978
// These are the reasonable defaults supported by the Node ecosystem.
8079
// We also include JSX as a common component filename extension to support
@@ -84,7 +83,7 @@ module.exports = {
8483
// for React Native Web.
8584
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
8685
alias: {
87-
86+
8887
// Support React Native Web
8988
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
9089
'react-native': 'react-native-web',
@@ -115,7 +114,7 @@ module.exports = {
115114
options: {
116115
formatter: eslintFormatter,
117116
eslintPath: require.resolve('eslint'),
118-
117+
119118
},
120119
loader: require.resolve('eslint-loader'),
121120
},
@@ -144,7 +143,7 @@ module.exports = {
144143
include: paths.appSrc,
145144
loader: require.resolve('babel-loader'),
146145
options: {
147-
146+
148147
// This is a feature of `babel-loader` for webpack (not Babel itself).
149148
// It enables caching results in ./node_modules/.cache/babel-loader/
150149
// directory for faster rebuilds.

‎config/webpack.config.prod.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
const autoprefixer = require('autoprefixer');
44
const path = require('path');
@@ -42,8 +42,8 @@ const cssFilename = 'static/css/[name].[contenthash:8].css';
4242
// However, our output is structured with css, js and media folders.
4343
// To have this structure working with relative paths, we have to use custom options.
4444
const extractTextPluginOptions = shouldUseRelativeAssetPaths
45-
? // Making sure that the publicPath goes back to to build folder.
46-
{ publicPath: Array(cssFilename.split('/').length).join('../') }
45+
// Making sure that the publicPath goes back to to build folder.
46+
? { publicPath: Array(cssFilename.split('/').length).join('../') }
4747
: {};
4848

4949
// This is the production configuration.
@@ -66,12 +66,11 @@ module.exports = {
6666
filename: 'static/js/[name].[chunkhash:8].js',
6767
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
6868
// We inferred the "public path" (such as / or /my-project) from homepage.
69-
publicPath: publicPath,
69+
publicPath,
7070
// Point sourcemap entries to original disk location (format as URL on Windows)
71-
devtoolModuleFilenameTemplate: info =>
72-
path
73-
.relative(paths.appSrc, info.absoluteResourcePath)
74-
.replace(/\\/g, '/'),
71+
devtoolModuleFilenameTemplate: info => path
72+
.relative(paths.appSrc, info.absoluteResourcePath)
73+
.replace(/\\/g, '/'),
7574
},
7675
resolve: {
7776
// This allows you to set a fallback for where Webpack should look for modules.
@@ -80,7 +79,7 @@ module.exports = {
8079
// https://github.com/facebookincubator/create-react-app/issues/253
8180
modules: ['node_modules', paths.appNodeModules].concat(
8281
// It is guaranteed to exist because we tweak it in `env.js`
83-
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
82+
process.env.NODE_PATH.split(path.delimiter).filter(Boolean),
8483
),
8584
// These are the reasonable defaults supported by the Node ecosystem.
8685
// We also include JSX as a common component filename extension to support
@@ -90,7 +89,7 @@ module.exports = {
9089
// for React Native Web.
9190
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
9291
alias: {
93-
92+
9493
// Support React Native Web
9594
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
9695
'react-native': 'react-native-web',
@@ -121,7 +120,7 @@ module.exports = {
121120
options: {
122121
formatter: eslintFormatter,
123122
eslintPath: require.resolve('eslint'),
124-
123+
125124
},
126125
loader: require.resolve('eslint-loader'),
127126
},
@@ -149,7 +148,7 @@ module.exports = {
149148
include: paths.appSrc,
150149
loader: require.resolve('babel-loader'),
151150
options: {
152-
151+
153152
compact: true,
154153
},
155154
},
@@ -207,8 +206,8 @@ module.exports = {
207206
},
208207
],
209208
},
210-
extractTextPluginOptions
211-
)
209+
extractTextPluginOptions,
210+
),
212211
),
213212
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
214213
},
@@ -316,7 +315,7 @@ module.exports = {
316315
},
317316
minify: true,
318317
// For unknown URLs, fallback to the index page
319-
navigateFallback: publicUrl + '/index.html',
318+
navigateFallback: `${publicUrl}/index.html`,
320319
// Ignores URLs starting from /__ (useful for Firebase):
321320
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
322321
navigateFallbackWhitelist: [/^(?!\/__).*/],

‎config/webpackDevServer.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
/* eslint-disable func-names */
22

33
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
44
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
@@ -9,7 +9,7 @@ const paths = require('./paths');
99
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
1010
const host = process.env.HOST || '0.0.0.0';
1111

12-
module.exports = function(proxy, allowedHost) {
12+
module.exports = function (proxy, allowedHost) {
1313
return {
1414
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
1515
// websites from potentially accessing local content through DNS rebinding:
@@ -72,7 +72,7 @@ module.exports = function(proxy, allowedHost) {
7272
},
7373
// Enable HTTPS if the HTTPS environment variable is set to 'true'
7474
https: protocol === 'https',
75-
host: host,
75+
host,
7676
overlay: false,
7777
historyApiFallback: {
7878
// Paths with dots should still use the history fallback.

‎package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
"scripts": {
6363
"start": "node scripts/start.js",
6464
"build": "node scripts/build.js",
65-
"test": "node scripts/test.js --env=jsdom"
65+
"test": "node scripts/test.js --env=jsdom",
66+
"lint": "eslint . --ext .js",
67+
"covdate": "mv coverage/coverage-summary.json coverage/coverage-summary-$(date +%Y%m%d%H%M).json"
6668
},
6769
"jest": {
6870
"collectCoverageFrom": [
@@ -71,6 +73,7 @@
7173
"setupFiles": [
7274
"<rootDir>/config/polyfills.js"
7375
],
76+
"setupTestFrameworkScriptFile": "<rootDir>/src/tests/setupTests.js",
7477
"testMatch": [
7578
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
7679
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"

‎scripts/build.js

+27-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
// Do this as the first thing so that any code reading it knows the right env.
44
process.env.BABEL_ENV = 'production';
@@ -7,7 +7,7 @@ process.env.NODE_ENV = 'production';
77
// Makes the script crash on unhandled rejections instead of silently
88
// ignoring them. In the future, promise rejections that are not handled will
99
// terminate the Node.js process with a non-zero exit code.
10-
process.on('unhandledRejection', err => {
10+
process.on('unhandledRejection', (err) => {
1111
throw err;
1212
});
1313

@@ -18,17 +18,16 @@ const path = require('path');
1818
const chalk = require('chalk');
1919
const fs = require('fs-extra');
2020
const webpack = require('webpack');
21-
const config = require('../config/webpack.config.prod');
22-
const paths = require('../config/paths');
2321
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
2422
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
2523
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
2624
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
2725
const printBuildError = require('react-dev-utils/printBuildError');
26+
const paths = require('../config/paths');
27+
const config = require('../config/webpack.config.prod');
2828

29-
const measureFileSizesBeforeBuild =
30-
FileSizeReporter.measureFileSizesBeforeBuild;
31-
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
29+
const { measureFileSizesBeforeBuild } = FileSizeReporter;
30+
const { printFileSizesAfterBuild } = FileSizeReporter;
3231
const useYarn = fs.existsSync(paths.yarnLockFile);
3332

3433
// These sizes are pretty large. We'll warn for bundles exceeding them.
@@ -43,7 +42,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
4342
// First, read the current file sizes in build directory.
4443
// This lets us display how much they changed later.
4544
measureFileSizesBeforeBuild(paths.appBuild)
46-
.then(previousFileSizes => {
45+
.then((previousFileSizes) => {
4746
// Remove all content but keep the directory so that
4847
// if you're in it, you don't end up in Trash
4948
fs.emptyDirSync(paths.appBuild);
@@ -58,14 +57,14 @@ measureFileSizesBeforeBuild(paths.appBuild)
5857
console.log(chalk.yellow('Compiled with warnings.\n'));
5958
console.log(warnings.join('\n\n'));
6059
console.log(
61-
'\nSearch for the ' +
62-
chalk.underline(chalk.yellow('keywords')) +
63-
' to learn more about each warning.'
60+
`\nSearch for the ${
61+
chalk.underline(chalk.yellow('keywords'))
62+
} to learn more about each warning.`,
6463
);
6564
console.log(
66-
'To ignore, add ' +
67-
chalk.cyan('// eslint-disable-next-line') +
68-
' to the line before.\n'
65+
`To ignore, add ${
66+
chalk.cyan('// eslint-disable-next-line')
67+
} to the line before.\n`,
6968
);
7069
} else {
7170
console.log(chalk.green('Compiled successfully.\n'));
@@ -77,34 +76,34 @@ measureFileSizesBeforeBuild(paths.appBuild)
7776
previousFileSizes,
7877
paths.appBuild,
7978
WARN_AFTER_BUNDLE_GZIP_SIZE,
80-
WARN_AFTER_CHUNK_GZIP_SIZE
79+
WARN_AFTER_CHUNK_GZIP_SIZE,
8180
);
8281
console.log();
8382

8483
const appPackage = require(paths.appPackageJson);
85-
const publicUrl = paths.publicUrl;
86-
const publicPath = config.output.publicPath;
84+
const { publicUrl } = paths;
85+
const { publicPath } = config.output;
8786
const buildFolder = path.relative(process.cwd(), paths.appBuild);
8887
printHostingInstructions(
8988
appPackage,
9089
publicUrl,
9190
publicPath,
9291
buildFolder,
93-
useYarn
92+
useYarn,
9493
);
9594
},
96-
err => {
95+
(err) => {
9796
console.log(chalk.red('Failed to compile.\n'));
9897
printBuildError(err);
9998
process.exit(1);
100-
}
99+
},
101100
);
102101

103102
// Create the production build and print the deployment instructions.
104103
function build(previousFileSizes) {
105104
console.log('Creating an optimized production build...');
106105

107-
let compiler = webpack(config);
106+
const compiler = webpack(config);
108107
return new Promise((resolve, reject) => {
109108
compiler.run((err, stats) => {
110109
if (err) {
@@ -120,16 +119,16 @@ function build(previousFileSizes) {
120119
return reject(new Error(messages.errors.join('\n\n')));
121120
}
122121
if (
123-
process.env.CI &&
124-
(typeof process.env.CI !== 'string' ||
125-
process.env.CI.toLowerCase() !== 'false') &&
126-
messages.warnings.length
122+
process.env.CI
123+
&& (typeof process.env.CI !== 'string'
124+
|| process.env.CI.toLowerCase() !== 'false')
125+
&& messages.warnings.length
127126
) {
128127
console.log(
129128
chalk.yellow(
130-
'\nTreating warnings as errors because process.env.CI = true.\n' +
131-
'Most CI servers set it automatically.\n'
132-
)
129+
'\nTreating warnings as errors because process.env.CI = true.\n'
130+
+ 'Most CI servers set it automatically.\n',
131+
),
133132
);
134133
return reject(new Error(messages.warnings.join('\n\n')));
135134
}

‎scripts/start.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
// Do this as the first thing so that any code reading it knows the right env.
44
process.env.BABEL_ENV = 'development';
@@ -7,7 +7,7 @@ process.env.NODE_ENV = 'development';
77
// Makes the script crash on unhandled rejections instead of silently
88
// ignoring them. In the future, promise rejections that are not handled will
99
// terminate the Node.js process with a non-zero exit code.
10-
process.on('unhandledRejection', err => {
10+
process.on('unhandledRejection', (err) => {
1111
throw err;
1212
});
1313

@@ -47,12 +47,12 @@ if (process.env.HOST) {
4747
console.log(
4848
chalk.cyan(
4949
`Attempting to bind to HOST environment variable: ${chalk.yellow(
50-
chalk.bold(process.env.HOST)
51-
)}`
52-
)
50+
chalk.bold(process.env.HOST),
51+
)}`,
52+
),
5353
);
5454
console.log(
55-
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
55+
'If this was unintentional, check that you haven\'t mistakenly set it in your shell.',
5656
);
5757
console.log(`Learn more here: ${chalk.yellow('http://bit.ly/2mwWSwH')}`);
5858
console.log();
@@ -61,7 +61,7 @@ if (process.env.HOST) {
6161
// We attempt to use the default port but if it is busy, we offer the user to
6262
// run on a different port. `choosePort()` Promise resolves to the next free port.
6363
choosePort(HOST, DEFAULT_PORT)
64-
.then(port => {
64+
.then((port) => {
6565
if (port == null) {
6666
// We have not found a port.
6767
return;
@@ -77,29 +77,29 @@ choosePort(HOST, DEFAULT_PORT)
7777
// Serve webpack assets generated by the compiler over a web sever.
7878
const serverConfig = createDevServerConfig(
7979
proxyConfig,
80-
urls.lanUrlForConfig
80+
urls.lanUrlForConfig,
8181
);
8282
const devServer = new WebpackDevServer(compiler, serverConfig);
8383
// Launch WebpackDevServer.
84-
devServer.listen(port, HOST, err => {
84+
devServer.listen(port, HOST, (err) => {
8585
if (err) {
8686
return console.log(err);
8787
}
8888
if (isInteractive) {
8989
clearConsole();
9090
}
9191
console.log(chalk.cyan('Starting the development server...\n'));
92-
openBrowser(urls.localUrlForBrowser);
92+
return openBrowser(urls.localUrlForBrowser);
9393
});
9494

95-
['SIGINT', 'SIGTERM'].forEach(function(sig) {
96-
process.on(sig, function() {
95+
['SIGINT', 'SIGTERM'].forEach((sig) => {
96+
process.on(sig, () => {
9797
devServer.close();
9898
process.exit();
9999
});
100100
});
101101
})
102-
.catch(err => {
102+
.catch((err) => {
103103
if (err && err.message) {
104104
console.log(err.message);
105105
}

‎scripts/test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
// Do this as the first thing so that any code reading it knows the right env.
42
process.env.BABEL_ENV = 'test';
53
process.env.NODE_ENV = 'test';
@@ -8,15 +6,16 @@ process.env.PUBLIC_URL = '';
86
// Makes the script crash on unhandled rejections instead of silently
97
// ignoring them. In the future, promise rejections that are not handled will
108
// terminate the Node.js process with a non-zero exit code.
11-
process.on('unhandledRejection', err => {
9+
process.on('unhandledRejection', (err) => {
1210
throw err;
1311
});
1412

1513
// Ensure environment variables are read.
1614
require('../config/env');
1715

1816
const jest = require('jest');
19-
let argv = process.argv.slice(2);
17+
18+
const argv = process.argv.slice(2);
2019

2120
// Watch unless on CI or in coverage mode
2221
if (!process.env.CI && argv.indexOf('--coverage') < 0) {

‎src/tests/App.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from '../templates/App';
44

5-
it('renders without crashing', () => {
5+
it('renders without crashing', () => { // eslint-disable-line no-undef
66
const div = document.createElement('div');
77
ReactDOM.render(<App />, div);
88
ReactDOM.unmountComponentAtNode(div);

‎src/tests/setupTests.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable no-undef */
2+
3+
const localStorageMock = {
4+
getItem: jest.fn(),
5+
setItem: jest.fn(),
6+
clear: jest.fn(),
7+
};
8+
9+
global.localStorage = localStorageMock;

0 commit comments

Comments
 (0)
Please sign in to comment.