Skip to content

Commit 0798617

Browse files
author
Matthew Grill
committed
Cleanup for rules.
1 parent 3d4ff0b commit 0798617

File tree

8 files changed

+174
-63
lines changed

8 files changed

+174
-63
lines changed

.eslintrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
"airbnb",
44
"plugin:prettier/recommended"
55
],
6+
"parser": "babel-eslint",
67
"env": {
78
"browser": true,
89
"es6": true,
910
"jest": true,
1011
"serviceworker": true
1112
},
1213
"rules": {
13-
"react/jsx-filename-extension": [1, { "extensions": [".js"] }]
14+
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
15+
"jsx-a11y/anchor-is-valid": [ "error", {
16+
"aspects": [ "noHref" ]
17+
}],
18+
"no-param-reassign": [2, { "props": false }]
1419
}
1520
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"private": true,
55
"dependencies": {
66
"emotion": "^9.0.2",
7+
"prop-types": "^15.6.1",
78
"react": "^16.2.0",
89
"react-dom": "^16.2.0",
910
"react-router-dom": "^4.2.2"
1011
},
1112
"devDependencies": {
13+
"babel-eslint": "^8.2.2",
1214
"eslint": "^4.9.0",
1315
"eslint-config-airbnb": "^16.1.0",
1416
"eslint-config-prettier": "^2.9.0",

src/App.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
import React, { Component } from 'react';
22
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
33

4+
import routes from './routes';
5+
46
import Home from './components/05_pages/Home/Home';
5-
import Permissions from './components/05_pages/Permissions/Permissions';
7+
import NoMatch from './NoMatch';
68

79
import normalize from './styles/normalize'; // eslint-disable-line no-unused-vars
810
import base from './styles/base'; // eslint-disable-line no-unused-vars
911

10-
class NoMatch extends Component {
11-
componentWillReceiveProps(nextProps) {
12-
if (!Object.keys(routes).includes(nextProps.location.pathname)) {
13-
window.location = window.location.href;
14-
}
15-
}
16-
render() {
17-
return null;
18-
}
19-
}
20-
21-
// @todo Share this with Drupal
22-
const routes = {
23-
'/admin/people/permissions': Permissions,
24-
};
25-
2612
class App extends Component {
2713
componentDidMount() {
2814
window.history.replaceState(null, null, '/');

src/NoMatch.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component } from 'react';
2+
import { shape, string } from 'prop-types';
3+
4+
import routes from './routes';
5+
6+
const NoMatch = class NoMatch extends Component {
7+
static propTypes = {
8+
location: shape({
9+
pathname: string.isRequired,
10+
}).isRequired,
11+
};
12+
componentWillReceiveProps(nextProps) {
13+
if (!Object.keys(routes).includes(nextProps.location.pathname)) {
14+
window.location = window.location.href;
15+
}
16+
}
17+
render() {
18+
return null;
19+
}
20+
};
21+
22+
export default NoMatch;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import React from 'react';
22
import { css } from 'emotion';
33

4+
const styles = {
5+
title: css`
6+
text-decoration: underline;
7+
`,
8+
};
9+
410
const Permissions = () => (
511
<div>
612
<h1 className={styles.title}>Permissions</h1>
713
<p>This will be the permissions page.</p>
814
</div>
915
);
1016

11-
const styles = {
12-
title: css`
13-
text-decoration: underline;
14-
`,
15-
};
16-
1717
export default Permissions;

src/registerServiceWorker.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,6 @@ const isLocalhost = Boolean(
1818
),
1919
);
2020

21-
export default function register() {
22-
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
23-
// The URL constructor is available in all browsers that support SW.
24-
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
25-
if (publicUrl.origin !== window.location.origin) {
26-
// Our service worker won't work if PUBLIC_URL is on a different origin
27-
// from what our page is served on. This might happen if a CDN is used to
28-
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
29-
return;
30-
}
31-
32-
window.addEventListener('load', () => {
33-
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
34-
35-
if (isLocalhost) {
36-
// This is running on localhost. Lets check if a service worker still exists or not.
37-
checkValidServiceWorker(swUrl);
38-
39-
// Add some additional logging to localhost, pointing developers to the
40-
// service worker/PWA documentation.
41-
navigator.serviceWorker.ready.then(() => {
42-
console.log(
43-
'This web app is being served cache-first by a service ' +
44-
'worker. To learn more, visit https://goo.gl/SC7cgQ',
45-
);
46-
});
47-
} else {
48-
// Is not local host. Just register service worker
49-
registerValidSW(swUrl);
50-
}
51-
});
52-
}
53-
}
54-
5521
function registerValidSW(swUrl) {
5622
navigator.serviceWorker
5723
.register(swUrl)
@@ -108,6 +74,40 @@ function checkValidServiceWorker(swUrl) {
10874
});
10975
}
11076

77+
export default function register() {
78+
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
79+
// The URL constructor is available in all browsers that support SW.
80+
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
81+
if (publicUrl.origin !== window.location.origin) {
82+
// Our service worker won't work if PUBLIC_URL is on a different origin
83+
// from what our page is served on. This might happen if a CDN is used to
84+
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
85+
return;
86+
}
87+
88+
window.addEventListener('load', () => {
89+
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
90+
91+
if (isLocalhost) {
92+
// This is running on localhost. Lets check if a service worker still exists or not.
93+
checkValidServiceWorker(swUrl);
94+
95+
// Add some additional logging to localhost, pointing developers to the
96+
// service worker/PWA documentation.
97+
navigator.serviceWorker.ready.then(() => {
98+
console.log(
99+
'This web app is being served cache-first by a service ' +
100+
'worker. To learn more, visit https://goo.gl/SC7cgQ',
101+
);
102+
});
103+
} else {
104+
// Is not local host. Just register service worker
105+
registerValidSW(swUrl);
106+
}
107+
});
108+
}
109+
}
110+
111111
export function unregister() {
112112
if ('serviceWorker' in navigator) {
113113
navigator.serviceWorker.ready.then(registration => {

src/routes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Permissions from './components/05_pages/Permissions/Permissions';
2+
3+
// @todo Share this with Drupal
4+
const routes = {
5+
'/admin/people/permissions': Permissions,
6+
};
7+
8+
export default routes;

yarn.lock

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,74 @@
22
# yarn lockfile v1
33

44

5+
"@babel/[email protected]", "@babel/code-frame@^7.0.0-beta.40":
6+
version "7.0.0-beta.40"
7+
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz#37e2b0cf7c56026b4b21d3927cadf81adec32ac6"
8+
dependencies:
9+
"@babel/highlight" "7.0.0-beta.40"
10+
11+
12+
version "7.0.0-beta.40"
13+
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0-beta.40.tgz#ab61f9556f4f71dbd1138949c795bb9a21e302ea"
14+
dependencies:
15+
"@babel/types" "7.0.0-beta.40"
16+
jsesc "^2.5.1"
17+
lodash "^4.2.0"
18+
source-map "^0.5.0"
19+
trim-right "^1.0.1"
20+
21+
22+
version "7.0.0-beta.40"
23+
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.40.tgz#9d033341ab16517f40d43a73f2d81fc431ccd7b6"
24+
dependencies:
25+
"@babel/helper-get-function-arity" "7.0.0-beta.40"
26+
"@babel/template" "7.0.0-beta.40"
27+
"@babel/types" "7.0.0-beta.40"
28+
29+
30+
version "7.0.0-beta.40"
31+
resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.40.tgz#ac0419cf067b0ec16453e1274f03878195791c6e"
32+
dependencies:
33+
"@babel/types" "7.0.0-beta.40"
34+
535
636
version "7.0.0-beta.32"
737
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0-beta.32.tgz#8126fc024107c226879841b973677a4f4e510a03"
838
dependencies:
939
"@babel/types" "7.0.0-beta.32"
1040
lodash "^4.2.0"
1141

42+
43+
version "7.0.0-beta.40"
44+
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.40.tgz#b43d67d76bf46e1d10d227f68cddcd263786b255"
45+
dependencies:
46+
chalk "^2.0.0"
47+
esutils "^2.0.2"
48+
js-tokens "^3.0.0"
49+
50+
51+
version "7.0.0-beta.40"
52+
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.40.tgz#034988c6424eb5c3268fe6a608626de1f4410fc8"
53+
dependencies:
54+
"@babel/code-frame" "7.0.0-beta.40"
55+
"@babel/types" "7.0.0-beta.40"
56+
babylon "7.0.0-beta.40"
57+
lodash "^4.2.0"
58+
59+
"@babel/traverse@^7.0.0-beta.40":
60+
version "7.0.0-beta.40"
61+
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.40.tgz#d140e449b2e093ef9fe1a2eecc28421ffb4e521e"
62+
dependencies:
63+
"@babel/code-frame" "7.0.0-beta.40"
64+
"@babel/generator" "7.0.0-beta.40"
65+
"@babel/helper-function-name" "7.0.0-beta.40"
66+
"@babel/types" "7.0.0-beta.40"
67+
babylon "7.0.0-beta.40"
68+
debug "^3.0.1"
69+
globals "^11.1.0"
70+
invariant "^2.2.0"
71+
lodash "^4.2.0"
72+
1273
1374
version "7.0.0-beta.32"
1475
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.32.tgz#c317d0ecc89297b80bbcb2f50608e31f6452a5ff"
@@ -17,6 +78,14 @@
1778
lodash "^4.2.0"
1879
to-fast-properties "^2.0.0"
1980

81+
"@babel/[email protected]", "@babel/types@^7.0.0-beta.40":
82+
version "7.0.0-beta.40"
83+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.40.tgz#25c3d7aae14126abe05fcb098c65a66b6d6b8c14"
84+
dependencies:
85+
esutils "^2.0.2"
86+
lodash "^4.2.0"
87+
to-fast-properties "^2.0.0"
88+
2089
abab@^1.0.3:
2190
version "1.0.4"
2291
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
@@ -414,6 +483,17 @@ [email protected]:
414483
babel-types "^6.23.0"
415484
babylon "^6.17.0"
416485

486+
babel-eslint@^8.2.2:
487+
version "8.2.2"
488+
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.2.tgz#1102273354c6f0b29b4ea28a65f97d122296b68b"
489+
dependencies:
490+
"@babel/code-frame" "^7.0.0-beta.40"
491+
"@babel/traverse" "^7.0.0-beta.40"
492+
"@babel/types" "^7.0.0-beta.40"
493+
babylon "^7.0.0-beta.40"
494+
eslint-scope "~3.7.1"
495+
eslint-visitor-keys "^1.0.0"
496+
417497
babel-generator@^6.18.0, babel-generator@^6.26.0:
418498
version "6.26.1"
419499
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90"
@@ -1023,6 +1103,10 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24
10231103
lodash "^4.17.4"
10241104
to-fast-properties "^1.0.3"
10251105

1106+
[email protected], babylon@^7.0.0-beta.40:
1107+
version "7.0.0-beta.40"
1108+
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.40.tgz#91fc8cd56d5eb98b28e6fde41045f2957779940a"
1109+
10261110
babylon@^6.17.0, babylon@^6.18.0:
10271111
version "6.18.0"
10281112
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
@@ -2488,7 +2572,7 @@ eslint-restricted-globals@^0.1.1:
24882572
version "0.1.1"
24892573
resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7"
24902574

2491-
eslint-scope@^3.7.1:
2575+
eslint-scope@^3.7.1, eslint-scope@~3.7.1:
24922576
version "3.7.1"
24932577
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
24942578
dependencies:
@@ -3169,7 +3253,7 @@ global-prefix@^1.0.1:
31693253
is-windows "^1.0.1"
31703254
which "^1.2.14"
31713255

3172-
globals@^11.0.1:
3256+
globals@^11.0.1, globals@^11.1.0:
31733257
version "11.3.0"
31743258
resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0"
31753259

@@ -3616,7 +3700,7 @@ interpret@^1.0.0:
36163700
version "1.1.0"
36173701
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
36183702

3619-
invariant@^2.2.1, invariant@^2.2.2:
3703+
invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2:
36203704
version "2.2.3"
36213705
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.3.tgz#1a827dfde7dcbd7c323f0ca826be8fa7c5e9d688"
36223706
dependencies:
@@ -4278,6 +4362,10 @@ jsesc@^1.3.0:
42784362
version "1.3.0"
42794363
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b"
42804364

4365+
jsesc@^2.5.1:
4366+
version "2.5.1"
4367+
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.1.tgz#e421a2a8e20d6b0819df28908f782526b96dd1fe"
4368+
42814369
jsesc@~0.5.0:
42824370
version "0.5.0"
42834371
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
@@ -5641,7 +5729,7 @@ promise@^7.1.1:
56415729
dependencies:
56425730
asap "~2.0.3"
56435731

5644-
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.6.0:
5732+
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.6.0, prop-types@^15.6.1:
56455733
version "15.6.1"
56465734
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
56475735
dependencies:
@@ -6500,7 +6588,7 @@ source-map-url@^0.4.0:
65006588
version "0.4.0"
65016589
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
65026590

6503-
[email protected], source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1:
6591+
[email protected], source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1:
65046592
version "0.5.7"
65056593
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
65066594

0 commit comments

Comments
 (0)