Skip to content

Commit 780c963

Browse files
committed
chore(react client): files linted
- Added jest to eslint rules - Linted files
1 parent b77296b commit 780c963

5 files changed

Lines changed: 30 additions & 20 deletions

File tree

apps/react-apirest/client/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
env: {
33
browser: true,
44
es6: true,
5+
jest: true
56
},
67
extends: [
78
'plugin:react/recommended',
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ function App() {
88
<header className="App-header">
99
<img src={logo} className="App-logo" alt="logo" />
1010
<p>
11-
Edit <code>src/App.js</code> and save to reload.
11+
Edit
12+
{' '}
13+
<code>src/App.js</code>
14+
{' '}
15+
and save to reload.
1216
</p>
1317
<a
1418
className="App-link"

apps/react-apirest/client/src/App.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint react/jsx-filename-extension: 0 */
12
import React from 'react';
23
import { render } from '@testing-library/react';
34
import App from './App';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ 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

apps/react-apirest/client/src/serviceWorker.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* eslint no-use-before-define: 0 */
2+
/* eslint no-console: 0 */
3+
/* eslint no-param-reassign: 0 */
4+
15
// This optional code is used to register a service worker.
26
// register() is not called by default.
37

@@ -11,13 +15,13 @@
1115
// opt-in, read https://bit.ly/CRA-PWA
1216

1317
const isLocalhost = Boolean(
14-
window.location.hostname === 'localhost' ||
18+
window.location.hostname === 'localhost'
1519
// [::1] is the IPv6 localhost address.
16-
window.location.hostname === '[::1]' ||
20+
|| window.location.hostname === '[::1]'
1721
// 127.0.0.0/8 are considered localhost for IPv4.
18-
window.location.hostname.match(
19-
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20-
)
22+
|| window.location.hostname.match(
23+
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
24+
),
2125
);
2226

2327
export function register(config) {
@@ -42,8 +46,8 @@ export function register(config) {
4246
// service worker/PWA documentation.
4347
navigator.serviceWorker.ready.then(() => {
4448
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'
49+
'This web app is being served cache-first by a service '
50+
+ 'worker. To learn more, visit https://bit.ly/CRA-PWA',
4751
);
4852
});
4953
} else {
@@ -57,7 +61,7 @@ export function register(config) {
5761
function registerValidSW(swUrl, config) {
5862
navigator.serviceWorker
5963
.register(swUrl)
60-
.then(registration => {
64+
.then((registration) => {
6165
registration.onupdatefound = () => {
6266
const installingWorker = registration.installing;
6367
if (installingWorker == null) {
@@ -70,8 +74,8 @@ function registerValidSW(swUrl, config) {
7074
// but the previous service worker will still serve the older
7175
// content until all client tabs are closed.
7276
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.'
77+
'New content is available and will be used when all '
78+
+ 'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
7579
);
7680

7781
// Execute callback
@@ -93,7 +97,7 @@ function registerValidSW(swUrl, config) {
9397
};
9498
};
9599
})
96-
.catch(error => {
100+
.catch((error) => {
97101
console.error('Error during service worker registration:', error);
98102
});
99103
}
@@ -103,15 +107,15 @@ function checkValidServiceWorker(swUrl, config) {
103107
fetch(swUrl, {
104108
headers: { 'Service-Worker': 'script' },
105109
})
106-
.then(response => {
110+
.then((response) => {
107111
// Ensure service worker exists, and that we really are getting a JS file.
108112
const contentType = response.headers.get('content-type');
109113
if (
110-
response.status === 404 ||
111-
(contentType != null && contentType.indexOf('javascript') === -1)
114+
response.status === 404
115+
|| (contentType != null && contentType.indexOf('javascript') === -1)
112116
) {
113117
// No service worker found. Probably a different app. Reload the page.
114-
navigator.serviceWorker.ready.then(registration => {
118+
navigator.serviceWorker.ready.then((registration) => {
115119
registration.unregister().then(() => {
116120
window.location.reload();
117121
});
@@ -123,18 +127,18 @@ function checkValidServiceWorker(swUrl, config) {
123127
})
124128
.catch(() => {
125129
console.log(
126-
'No internet connection found. App is running in offline mode.'
130+
'No internet connection found. App is running in offline mode.',
127131
);
128132
});
129133
}
130134

131135
export function unregister() {
132136
if ('serviceWorker' in navigator) {
133137
navigator.serviceWorker.ready
134-
.then(registration => {
138+
.then((registration) => {
135139
registration.unregister();
136140
})
137-
.catch(error => {
141+
.catch((error) => {
138142
console.error(error.message);
139143
});
140144
}

0 commit comments

Comments
 (0)