Skip to content

Commit c5227ea

Browse files
author
Chandan Rai
authored
[election:web] upgrade dependencies, reduce build time (#126)
* [election] add cache flag to lint * [election] remove auto formatting * [election:web] upgrade dependencies * [election:web] move testing libs to devDepedencies * [election:web] fix build errors post deps upgrade * [election:web] add --production flag in build.sh * [election:web] add brunch devdependency * [election:web] move brunch to dependencies * [election:web] remove unused refs * [election:web] bring back corejs * [election:web] Fix minigraph error
1 parent a24e7a3 commit c5227ea

File tree

9 files changed

+53
-73
lines changed

9 files changed

+53
-73
lines changed

election/transformed-data/counties.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47439,7 +47439,7 @@
4743947439
"candidates": {}
4744047440
}
4744147441
},
47442-
"total": {}
47442+
"total": {}
4744347443
},
4744447444
"AK": {
4744547445
"counties": {
@@ -48062,12 +48062,12 @@
4806248062
"TT": {
4806348063
"total": {
4806448064
"constitution": 3807,
48065-
"democrat": 188794,
48065+
"democrat": 81195417,
4806648066
"green": 8075,
48067-
"libertarian": 23004,
48067+
"libertarian": 1791587,
4806848068
"no party affiliation": 255060,
48069-
"others": 12386,
48070-
"republican": 489371,
48069+
"others": 217363,
48070+
"republican": 74022587,
4807148071
"better for america": 5825,
4807248072
"independent": 1063,
4807348073
"prohibition": 715,

election/web/.eslintrc.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
browser: true,
44
es6: true,
55
},
6-
extends: ['plugin:react/recommended', 'google', 'prettier', 'prettier/react'],
6+
extends: ['plugin:react/recommended', 'google', 'prettier'],
77
globals: {
88
Atomics: 'readonly',
99
SharedArrayBuffer: 'readonly',
@@ -19,17 +19,18 @@ module.exports = {
1919
plugins: ['react', 'prettier', 'react-hooks', 'import'],
2020
rules: {
2121
'require-jsdoc': 0,
22-
'prettier/prettier': 'error',
22+
'prettier/prettier': 0,
2323
'no-invalid-this': 0,
2424
'react/prop-types': 0,
25+
quotes: [0, "single", { "avoidEscape": true }],
2526
'react-hooks/rules-of-hooks': 'warn',
2627
'react-hooks/exhaustive-deps': 'error',
2728
'import/no-unresolved': [2, {commonjs: true, amd: true}],
2829
'import/named': 2,
2930
'import/default': 2,
3031
'import/export': 2,
3132
'import/order': [
32-
2,
33+
0,
3334
{
3435
groups: [
3536
'index',

election/web/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
npm install
2+
npm install --production
33
npm run build

election/web/package.json

Lines changed: 29 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,48 @@
77
"@material-ui/core": "^4.11.0",
88
"@material-ui/icons": "^4.9.1",
99
"@primer/octicons-v2-react": "0.0.0-53e900d",
10-
"@testing-library/jest-dom": "^5.11.0",
11-
"@testing-library/react": "^10.4.3",
12-
"ag-grid-community": "^24.0.0",
13-
"ag-grid-react": "^24.0.0",
10+
"ag-grid-community": "^25.1.0",
11+
"ag-grid-react": "^25.1.0",
1412
"axios": "^0.21.1",
1513
"classnames": "^2.2.6",
1614
"core-js": "^3.6.5",
1715
"corejs-typeahead": "^1.3.1",
1816
"d3-array": "^2.4.0",
19-
"d3-axis": "^1.0.12",
20-
"d3-fetch": "^1.2.0",
21-
"d3-format": "^1.4.4",
22-
"d3-geo": "^1.12.1",
23-
"d3-interpolate": "^1.4.0",
17+
"d3-axis": "^2.1.0",
18+
"d3-fetch": "^2.0.0",
19+
"d3-format": "^2.0.0",
20+
"d3-geo": "^2.0.1",
21+
"d3-interpolate": "^2.0.1",
2422
"d3-interpolate-path": "^2.1.2",
2523
"d3-scale": "^3.2.1",
26-
"d3-scale-chromatic": "^1.5.0",
27-
"d3-selection": "^1.4.1",
28-
"d3-shape": "^1.3.7",
29-
"d3-transition": "^1.3.2",
24+
"d3-scale-chromatic": "^2.0.0",
25+
"d3-selection": "^2.0.0",
26+
"d3-shape": "^2.1.0",
27+
"d3-transition": "^2.0.0",
3028
"date-fns": "^2.14.0",
3129
"date-fns-tz": "^1.0.10",
3230
"fast-deep-equal": "^3.1.3",
3331
"immer": "^8.0.1",
3432
"lodash": "^4.17.15",
3533
"luxon": "^1.25.0",
3634
"mobx": "^6.1.4",
37-
"react": "^16.13.1",
38-
"react-content-loader": "^5.1.0",
39-
"react-dom": "^16.13.1",
35+
"react": "^17.0.1",
36+
"react-content-loader": "^6.0.2",
37+
"react-dom": "^17.0.1",
4038
"react-feather": "^2.0.8",
4139
"react-helmet": "^6.1.0",
42-
"react-notifications-component": "^2.4.0",
40+
"react-notifications-component": "^3.0.4",
4341
"react-router-dom": "^5.2.0",
44-
"react-scripts": "^3.4.3",
42+
"react-scripts": "^4.0.3",
4543
"react-spring": "^8.0.27",
46-
"react-swipeable": "^5.5.1",
47-
"react-syntax-highlighter": "^13.5.3",
44+
"react-swipeable": "^6.1.0",
45+
"react-syntax-highlighter": "^15.4.3",
4846
"react-table": "^7.5.0",
49-
"react-use": "^15.3.0",
50-
"react-use-gesture": "^7.0.15",
47+
"react-use": "^17.2.1",
48+
"react-use-gesture": "^9.1.3",
5149
"redoc": "^2.0.0-rc.40",
5250
"styled-components": "^5.2.0",
53-
"swr": "^0.2.3",
51+
"swr": "^0.5.2",
5452
"topojson": "^3.0.2",
5553
"use-dark-mode": "^2.3.1",
5654
"workerize-loader": "^1.3.0"
@@ -62,9 +60,8 @@
6260
"compress_maps": "rollup -c",
6361
"test": "react-scripts test --testPathIgnorePatterns=src/tests/mapAndApiStateNames.test.js",
6462
"test:map": "react-scripts test src/tests/mapAndApiStateNames.test.js",
65-
"eslint": "eslint .",
66-
"eslint:fix": "eslint --fix --max-warnings=0",
67-
"format": "prettier --write \"**/*.+(js|jsx|json|yml|yaml|md|html)\"",
63+
"eslint": "eslint . --cache --quite",
64+
"eslint:fix": "eslint . --fix --max-warnings=0",
6865
"scss-lint": "sass-lint 'src/**/*.scss' -v -f table --max-warnings 0",
6966
"scss-lint:fix": "sass-lint-auto-fix 'src/**/*.scss' -d -h -c '.sass-lint-auto-fix.yml'",
7067
"analyze": "source-map-explorer 'build/static/js/*.js'",
@@ -75,44 +72,26 @@
7572
"eslintConfig": {
7673
"extends": "react-app"
7774
},
78-
"husky": {
79-
"hooks": {
80-
"pre-commit": "lint-staged"
81-
}
82-
},
83-
"lint-staged": {
84-
"*.+(js|jsx)": [
85-
"npm run eslint:fix",
86-
"prettier --write \"**/*.+(js|jsx)\""
87-
],
88-
"*.+(json|yml|yaml|md)": [
89-
"prettier --write \"**/*.+(json|yml|yaml|md)\""
90-
],
91-
"*.+(css|scss)": [
92-
"npm run scss-lint:fix",
93-
"npm run scss-lint"
94-
]
95-
},
9675
"devDependencies": {
97-
"@welldone-software/why-did-you-render": "^4.2.5",
76+
"@testing-library/jest-dom": "^5.11.0",
77+
"@testing-library/react": "^11.2.5",
78+
"@welldone-software/why-did-you-render": "^6.1.0",
9879
"enzyme": "^3.11.0",
9980
"enzyme-adapter-react-16": "^1.15.2",
10081
"eslint-config-google": "^0.14.0",
101-
"eslint-config-prettier": "^6.11.0",
82+
"eslint-config-prettier": "^8.1.0",
10283
"eslint-plugin-import": "^2.22.0",
10384
"eslint-plugin-prettier": "^3.1.4",
10485
"eslint-plugin-react": "^7.20.0",
10586
"http-server": "^0.12.3",
106-
"husky": "^4.2.5",
107-
"lint-staged": "^10.2.11",
108-
"node-sass": "^4.14.1",
87+
"node-sass": "^5.0.0",
10988
"prettier": "^2.0.5",
11089
"rollup": "^2.18.1",
11190
"rollup-plugin-copy": "^3.3.0",
11291
"sass-lint": "^1.13.1",
11392
"sass-lint-auto-fix": "^0.21.0",
11493
"source-map-explorer": "^2.4.2",
115-
"workbox-build": "^5.1.3"
94+
"workbox-build": "^6.1.1"
11695
},
11796
"browserslist": {
11897
"production": [

election/web/src/components/Build.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function Build() {
2727
<h2>
2828
The Github project for this React application is <a href="https://github.com/nimbella/demo-projects/tree/master/election" target="_blank" rel="noopener noreferrer">here</a>:
2929
</h2>
30-
<p>This project is built with a React front-end for the user interface. The front-end is backed by the <a href="#/api">Nimbella Election API</a>. As an example, let's show you how to share exit poll data in your application.</p>
31-
<p>It's as simple as 1, 2, 3 &amp; deploy.</p>
30+
<p>This project is built with a React front-end for the user interface. The front-end is backed by the <a href="#/api">Nimbella Election API</a>. As an example, let&apos;s show you how to share exit poll data in your application.</p>
31+
<p>It&apos;s as simple as 1, 2, 3 &amp; deploy.</p>
3232
<ol>
3333
<li>
3434
<p>In your front-end React application, import the following.</p>
@@ -88,7 +88,7 @@ useEffect(() => {
8888
</SyntaxHighlighter>
8989
</li>
9090
</ol>
91-
<p>You're one <b>deploy</b> step away from sharing your inspiration with the world.</p>
91+
<p>You&apos;re one <b>deploy</b> step away from sharing your inspiration with the world.</p>
9292
<h2>How to deploy your project</h2>
9393
<p>
9494
This project is built for the Nimbella cloud. This means you can share your project with the world by deploying the application
@@ -119,9 +119,9 @@ useEffect(() => {
119119
<SyntaxHighlighter language="javascript" style={darkMode.value ? darcula : prism}>
120120
GOOGLE_CIVIC_API_TOKEN=&lt;your_google_api_key&gt; nim project deploy github:nimbella/demo-projects/election
121121
</SyntaxHighlighter>
122-
<p>If you are in a hurry and don't want to grab a <a href="https://developers.google.com/civic-information" target="_blank" rel="noopener noreferrer">Google Civic Information API Key</a> yet, you can still deploy and use this app. Simply clone this repo locally, prepend the <b>API_ROOT_URL</b> value with <b>https://electiondemo-apigcp.nimbella.io</b> in <b>constants.js</b> and deploy using `nim project deploy demo-projects/election`. That's it, you can skip below steps.</p>
122+
<p>If you are in a hurry and don&apos;t want to grab a <a href="https://developers.google.com/civic-information" target="_blank" rel="noopener noreferrer">Google Civic Information API Key</a> yet, you can still deploy and use this app. Simply clone this repo locally, prepend the <b>API_ROOT_URL</b> value with <b>https://electiondemo-apigcp.nimbella.io</b> in <b>constants.js</b> and deploy using `nim project deploy demo-projects/election`. That&apos;s it, you can skip below steps.</p>
123123

124-
<p>If you did not sign up with a GitHub id, then clone the project locally first, then deploy. This is because the GitHub rate limits are too low to deploy without cloning unless you're authenticated with GitHub.</p>
124+
<p>If you did not sign up with a GitHub id, then clone the project locally first, then deploy. This is because the GitHub rate limits are too low to deploy without cloning unless you&apos;re authenticated with GitHub.</p>
125125
<SyntaxHighlighter language="javascript" style={darkMode.value ? darcula : prism}>
126126
{`git clone https://github.com/nimbella/demo-projects.git
127127
export GOOGLE_CIVIC_API_TOKEN=<your_google_api_key>

election/web/src/components/Contest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Contest() {
1414
/>
1515
</Helmet>
1616
<div className="jumbotron">
17-
<h1>Don't let the year 2020 be a drag</h1>
17+
<h1>Don&apos;t let the year 2020 be a drag</h1>
1818
<p>Extend these election-related APIs/app and build your own election app to inspire your friends, family <span role="img" aria-label="family">👪</span>, and everyone you know to win <span role="img" aria-label="award">🏆</span> $2020.</p>
1919
<a href="https://nimbella.com/election2020" rel="noopener noreferrer" target="_blank">
2020
<img alt="Election2020ContestBanner" src={banner} />

election/web/src/components/MapVisualizer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
interpolatePurples,
3434
interpolateOranges,
3535
} from 'd3-scale-chromatic';
36-
import {select, event} from 'd3-selection';
36+
import {select} from 'd3-selection';
3737
import {transition} from 'd3-transition';
3838
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
3939
import {useHistory} from 'react-router-dom';
@@ -253,7 +253,7 @@ function MapVisualizer({
253253
if (onceTouchedRegion.current === d) onceTouchedRegion.current = null;
254254
else onceTouchedRegion.current = d;
255255
})
256-
.on('click', (d) => {
256+
.on('click', (event, d) => {
257257
event.stopPropagation();
258258
const stateCode = STATE_CODES[d.properties.st_nm];
259259
if (
@@ -361,7 +361,7 @@ function MapVisualizer({
361361
onceTouchedRegion.current = null;
362362
else onceTouchedRegion.current = feature;
363363
})
364-
.on('click', (feature) => {
364+
.on('click', (event, feature) => {
365365
event.stopPropagation();
366366
if (onceTouchedRegion.current || mapMeta.mapType === MAP_TYPES.STATE)
367367
return;

election/web/src/components/Minigraphs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function Minigraphs({timeseries, date: timelineDate}) {
9292
const previous = select(this).attr('d');
9393
const current = linePath(date);
9494
return interpolatePath(previous, current);
95-
})
95+
}).selection()
9696
);
9797

9898
svg
@@ -127,7 +127,7 @@ function Minigraphs({timeseries, date: timelineDate}) {
127127
.attr('cx', (year) => xScale(year))
128128
.attr('cy', (year) =>
129129
yScale(getStatistic(timeseries[year], 'delta', statistic))
130-
)
130+
).selection()
131131
);
132132
});
133133
}, [years, timeseries]);

election/web/src/components/Timeseries.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {min, max, bisector} from 'd3-array';
1111
import {axisBottom, axisRight} from 'd3-axis';
1212
import {interpolatePath} from 'd3-interpolate-path';
1313
import { scaleLinear, scaleLog } from 'd3-scale';
14-
import {select, mouse} from 'd3-selection';
14+
import {select, pointer} from 'd3-selection';
1515
import {line, curveMonotoneX} from 'd3-shape';
1616
// eslint-disable-next-line
1717
import {transition} from 'd3-transition';
@@ -167,7 +167,7 @@ function Timeseries({timeseries, years, chartType, isUniform, isLog}) {
167167
};
168168

169169
function mousemove() {
170-
const xm = mouse(this)[0];
170+
const xm = pointer(this)[0];
171171
const year = xScale.invert(xm);
172172
if (!isNaN(year)) {
173173
const bisectDate = bisector((year) => year).left;
@@ -274,7 +274,7 @@ function Timeseries({timeseries, years, chartType, isUniform, isLog}) {
274274
const previous = select(this).attr('d');
275275
const current = linePath(year);
276276
return interpolatePath(previous, current);
277-
})
277+
}).selection()
278278
);
279279
} else {
280280
/* ELECTION TRENDS */

0 commit comments

Comments
 (0)