Skip to content

Commit 8eba7b9

Browse files
committed
init
1 parent 6d90baa commit 8eba7b9

File tree

11 files changed

+78
-41
lines changed

11 files changed

+78
-41
lines changed

.github/workflows/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* @philipluk
2+
*.js @philipluk
3+
*.yml @philipluk
4+
/public/ @philipluk

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
coverage
3+
node_modules
4+
package-lock.json

.prettierrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": false,
7+
"jsxSingleQuote": false,
8+
"printWidth": 80,
9+
"proseWrap": "preserve",
10+
"quoteProps": "as-needed",
11+
"requirePragma": false,
12+
"semi": true,
13+
"singleQuote": false,
14+
"tabWidth": 2,
15+
"trailingComma": "es5",
16+
"useTabs": false,
17+
"vueIndentScriptAndStyle": false
18+
}

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"start": "react-scripts start",
1515
"build": "react-scripts build",
1616
"test": "react-scripts test",
17-
"eject": "react-scripts eject"
17+
"eject": "react-scripts eject",
18+
"format:check": "prettier --check \"**/*.{js,jsx,yml,yaml,json,css,scss,md}\"",
19+
"format:write": "prettier --write \"**/*.{js,jsx,yml,yaml,json,css,scss,md}\""
1820
},
1921
"eslintConfig": {
2022
"extends": "react-app"
@@ -30,5 +32,8 @@
3032
"last 1 firefox version",
3133
"last 1 safari version"
3234
]
35+
},
36+
"devDependencies": {
37+
"prettier": "2.0.2"
3338
}
3439
}

src/App.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React from "react";
2+
import logo from "./logo.svg";
3+
import "./App.css";
44

55
function App() {
66
return (
@@ -16,7 +16,7 @@ function App() {
1616
target="_blank"
1717
rel="noopener noreferrer"
1818
>
19-
Learn React
19+
Phil Learn React
2020
</a>
2121
</header>
2222
</div>

src/App.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from 'react';
2-
import { render } from '@testing-library/react';
3-
import App from './App';
1+
import React from "react";
2+
import { render } from "@testing-library/react";
3+
import App from "./App";
44

5-
test('renders learn react link', () => {
5+
test("renders learn react link", () => {
66
const { getByText } = render(<App />);
77
const linkElement = getByText(/learn react/i);
88
expect(linkElement).toBeInTheDocument();

src/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
body {
22
margin: 0;
3-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
3+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
4+
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
55
sans-serif;
66
-webkit-font-smoothing: antialiased;
77
-moz-osx-font-smoothing: grayscale;
88
}
99

1010
code {
11-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
11+
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
1212
monospace;
1313
}

src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
import * as serviceWorker from './serviceWorker';
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import "./index.css";
4+
import App from "./App";
5+
import * as serviceWorker from "./serviceWorker";
66

77
ReactDOM.render(
88
<React.StrictMode>
99
<App />
1010
</React.StrictMode>,
11-
document.getElementById('root')
11+
document.getElementById("root")
1212
);
1313

1414
// If you want your app to work offline and load faster, you can change

src/serviceWorker.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
// opt-in, read https://bit.ly/CRA-PWA
1212

1313
const isLocalhost = Boolean(
14-
window.location.hostname === 'localhost' ||
14+
window.location.hostname === "localhost" ||
1515
// [::1] is the IPv6 localhost address.
16-
window.location.hostname === '[::1]' ||
16+
window.location.hostname === "[::1]" ||
1717
// 127.0.0.0/8 are considered localhost for IPv4.
1818
window.location.hostname.match(
1919
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
2020
)
2121
);
2222

2323
export function register(config) {
24-
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
24+
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
2525
// The URL constructor is available in all browsers that support SW.
2626
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
2727
if (publicUrl.origin !== window.location.origin) {
@@ -31,7 +31,7 @@ export function register(config) {
3131
return;
3232
}
3333

34-
window.addEventListener('load', () => {
34+
window.addEventListener("load", () => {
3535
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
3636

3737
if (isLocalhost) {
@@ -42,8 +42,8 @@ export function register(config) {
4242
// service worker/PWA documentation.
4343
navigator.serviceWorker.ready.then(() => {
4444
console.log(
45-
'This web app is being served cache-first by a service ' +
46-
'worker. To learn more, visit https://bit.ly/CRA-PWA'
45+
"This web app is being served cache-first by a service " +
46+
"worker. To learn more, visit https://bit.ly/CRA-PWA"
4747
);
4848
});
4949
} else {
@@ -57,21 +57,21 @@ export function register(config) {
5757
function registerValidSW(swUrl, config) {
5858
navigator.serviceWorker
5959
.register(swUrl)
60-
.then(registration => {
60+
.then((registration) => {
6161
registration.onupdatefound = () => {
6262
const installingWorker = registration.installing;
6363
if (installingWorker == null) {
6464
return;
6565
}
6666
installingWorker.onstatechange = () => {
67-
if (installingWorker.state === 'installed') {
67+
if (installingWorker.state === "installed") {
6868
if (navigator.serviceWorker.controller) {
6969
// At this point, the updated precached content has been fetched,
7070
// but the previous service worker will still serve the older
7171
// content until all client tabs are closed.
7272
console.log(
73-
'New content is available and will be used when all ' +
74-
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
73+
"New content is available and will be used when all " +
74+
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
7575
);
7676

7777
// Execute callback
@@ -82,7 +82,7 @@ function registerValidSW(swUrl, config) {
8282
// At this point, everything has been precached.
8383
// It's the perfect time to display a
8484
// "Content is cached for offline use." message.
85-
console.log('Content is cached for offline use.');
85+
console.log("Content is cached for offline use.");
8686

8787
// Execute callback
8888
if (config && config.onSuccess) {
@@ -93,25 +93,25 @@ function registerValidSW(swUrl, config) {
9393
};
9494
};
9595
})
96-
.catch(error => {
97-
console.error('Error during service worker registration:', error);
96+
.catch((error) => {
97+
console.error("Error during service worker registration:", error);
9898
});
9999
}
100100

101101
function checkValidServiceWorker(swUrl, config) {
102102
// Check if the service worker can be found. If it can't reload the page.
103103
fetch(swUrl, {
104-
headers: { 'Service-Worker': 'script' },
104+
headers: { "Service-Worker": "script" },
105105
})
106-
.then(response => {
106+
.then((response) => {
107107
// Ensure service worker exists, and that we really are getting a JS file.
108-
const contentType = response.headers.get('content-type');
108+
const contentType = response.headers.get("content-type");
109109
if (
110110
response.status === 404 ||
111-
(contentType != null && contentType.indexOf('javascript') === -1)
111+
(contentType != null && contentType.indexOf("javascript") === -1)
112112
) {
113113
// No service worker found. Probably a different app. Reload the page.
114-
navigator.serviceWorker.ready.then(registration => {
114+
navigator.serviceWorker.ready.then((registration) => {
115115
registration.unregister().then(() => {
116116
window.location.reload();
117117
});
@@ -123,18 +123,18 @@ function checkValidServiceWorker(swUrl, config) {
123123
})
124124
.catch(() => {
125125
console.log(
126-
'No internet connection found. App is running in offline mode.'
126+
"No internet connection found. App is running in offline mode."
127127
);
128128
});
129129
}
130130

131131
export function unregister() {
132-
if ('serviceWorker' in navigator) {
132+
if ("serviceWorker" in navigator) {
133133
navigator.serviceWorker.ready
134-
.then(registration => {
134+
.then((registration) => {
135135
registration.unregister();
136136
})
137-
.catch(error => {
137+
.catch((error) => {
138138
console.error(error.message);
139139
});
140140
}

0 commit comments

Comments
 (0)