Commit a59c3741 authored by marsandheart's avatar marsandheart

add prettier,redux,rematch

parent ad6f5a92
module.exports = {
printWidth: 100,
parser: "flow",
singleQuote: true,
arrowParens: 'always',
};
\ No newline at end of file
......@@ -3,18 +3,24 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@rematch/core": "^1.3.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
"react-redux": "^7.1.3",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"redux": "^4.0.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"prt": "node prt.js"
},
"eslintConfig": {
"extends": "react-app"
......@@ -30,5 +36,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "1.19.1"
}
}
const fs = require("fs");
const path = require("path");
const prettier = require("prettier");
const config = require("./.prettierrc");
const dir = './src';
mapAndFormat(dir);
function mapAndFormat(filePath) {
let files = fs.readdirSync(filePath);
files.forEach(fileName => {
const fullFIleName = `${filePath}/${fileName}`;
const stat = fs.statSync(fullFIleName);
const isDirectory = stat.isDirectory(fullFIleName);
const isJSFile = stat.isFile(fullFIleName) && (path.extname(fileName) === '.js');
if (isDirectory) {
mapAndFormat(fullFIleName);
} else if (isJSFile) {
const text = fs.readFileSync(fullFIleName, 'utf8');
const formatted = prettier.format(text, config);
fs.writeFileSync(fullFIleName, formatted);
}
});
}
......@@ -15,9 +15,7 @@ const isLocalhost = Boolean(
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);
export function register(config) {
......@@ -57,7 +55,7 @@ export function register(config) {
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
......@@ -93,7 +91,7 @@ function registerValidSW(swUrl, config) {
};
};
})
.catch(error => {
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
......@@ -103,7 +101,7 @@ function checkValidServiceWorker(swUrl, config) {
fetch(swUrl, {
headers: { 'Service-Worker': 'script' }
})
.then(response => {
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
......@@ -111,7 +109,7 @@ function checkValidServiceWorker(swUrl, config) {
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
......@@ -122,15 +120,13 @@ function checkValidServiceWorker(swUrl, config) {
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
console.log('No internet connection found. App is running in offline mode.');
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment