Skip to content

Commit 36ba0dc

Browse files
author
Andrew Luca
committed
chore: autoformat files before commit
Revert eslint changes when facebook/create-react-app#6513 will be merged Revert to react-scripts when facebook/create-react-app#5829 will be merged
1 parent 8281cc7 commit 36ba0dc

File tree

12 files changed

+750
-212
lines changed

12 files changed

+750
-212
lines changed

.eslintrc.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"extends": "react-app",
3+
"overrides": [
4+
{
5+
"files": ["**/*.ts", "**/*.tsx"],
6+
"parser": "@typescript-eslint/parser",
7+
"parserOptions": {
8+
"ecmaVersion": 2018,
9+
"sourceType": "module",
10+
"ecmaFeatures": {
11+
"jsx": true
12+
},
13+
"warnOnUnsupportedTypeScriptVersion": true
14+
},
15+
"plugins": ["@typescript-eslint"],
16+
"rules": {
17+
"camelcase": "off",
18+
"indent": "off",
19+
"no-array-constructor": "off",
20+
"no-unused-vars": "off",
21+
"@typescript-eslint/no-angle-bracket-type-assertion": "warn",
22+
"@typescript-eslint/no-array-constructor": "warn",
23+
"@typescript-eslint/no-namespace": "error",
24+
"@typescript-eslint/no-unused-vars": [
25+
"warn",
26+
{
27+
"args": "none",
28+
"ignoreRestSiblings": true
29+
}
30+
]
31+
}
32+
}
33+
]
34+
}

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false,
4+
"trailingComma": "all",
5+
"jsxBracketSameLine": true,
6+
"endOfLine": "lf"
7+
}

config/webpack.config.override.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = function(config) {
2+
// load eslint from file
3+
// revert on https://github.com/facebook/create-react-app/pull/6513
4+
const eslintRule = config.module.rules[1]
5+
eslintRule.test = /\.(js|mjs|jsx|ts|tsx)$/
6+
const eslintOptions = eslintRule.use[0].options
7+
delete eslintOptions.baseConfig
8+
delete eslintOptions.ignore
9+
delete eslintOptions.useEslintrc
10+
11+
return config
12+
}

package.json

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@types/jest": "24.0.10",
7-
"@types/node": "11.10.5",
8-
"@types/react": "16.8.7",
9-
"@types/react-dom": "16.8.2",
10-
"@types/storybook__addon-actions": "^3.4.2",
11-
"@types/storybook__addon-links": "^3.3.4",
12-
"@types/storybook__react": "^4.0.1",
136
"react": "^16.8.4",
147
"react-dom": "^16.8.4",
15-
"react-scripts": "2.1.8",
16-
"typescript": "3.3.3333"
8+
"@winify/react-scripts": "2.1.5"
179
},
1810
"scripts": {
1911
"start": "react-scripts start",
@@ -23,9 +15,6 @@
2315
"storybook": "start-storybook -p 9009 -s public",
2416
"build-storybook": "build-storybook -s public"
2517
},
26-
"eslintConfig": {
27-
"extends": "react-app"
28-
},
2918
"browserslist": [
3019
">0.2%",
3120
"not dead",
@@ -38,6 +27,30 @@
3827
"@storybook/addon-links": "^5.0.1",
3928
"@storybook/addons": "^5.0.1",
4029
"@storybook/react": "^5.0.1",
41-
"babel-loader": "^8.0.5"
30+
"@types/jest": "24.0.10",
31+
"@types/node": "11.10.5",
32+
"@types/react": "16.8.7",
33+
"@types/react-dom": "16.8.2",
34+
"@types/storybook__addon-actions": "^3.4.2",
35+
"@types/storybook__addon-links": "^3.3.4",
36+
"@types/storybook__react": "^4.0.1",
37+
"@typescript-eslint/eslint-plugin": "^1.4.2",
38+
"@typescript-eslint/parser": "^1.4.2",
39+
"babel-loader": "^8.0.5",
40+
"husky": "^1.3.1",
41+
"lint-staged": "^8.1.5",
42+
"prettier": "^1.16.4",
43+
"typescript": "3.3.3333"
44+
},
45+
"husky": {
46+
"hooks": {
47+
"pre-commit": "lint-staged"
48+
}
49+
},
50+
"lint-staged": {
51+
"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
52+
"prettier --write",
53+
"git add"
54+
]
4255
}
4356
}

src/app.component.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import App from './app.component';
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import App from './app.component'
44

55
it('renders without crashing', () => {
6-
const div = document.createElement('div');
7-
ReactDOM.render(<App />, div);
8-
ReactDOM.unmountComponentAtNode(div);
9-
});
6+
const div = document.createElement('div')
7+
ReactDOM.render(<App />, div)
8+
ReactDOM.unmountComponentAtNode(div)
9+
})

src/app.component.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { Component } from 'react';
2-
import logo from './logo.svg';
3-
import './app.component.css';
1+
import React, { Component } from 'react'
2+
import logo from './logo.svg'
3+
import './app.component.css'
44

55
class App extends Component {
66
render() {
@@ -15,14 +15,13 @@ class App extends Component {
1515
className="App-link"
1616
href="https://reactjs.org"
1717
target="_blank"
18-
rel="noopener noreferrer"
19-
>
18+
rel="noopener noreferrer">
2019
Learn React
2120
</a>
2221
</header>
2322
</div>
24-
);
23+
)
2524
}
2625
}
2726

28-
export default App;
27+
export default App

src/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './app.component';
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.component'
5+
import * as serviceWorker from './serviceWorker'
66

7-
ReactDOM.render(<App />, document.getElementById('root'));
7+
ReactDOM.render(<App />, document.getElementById('root'))
88

99
// If you want your app to work offline and load faster, you can change
1010
// unregister() to register() below. Note this comes with some pitfalls.
1111
// Learn more about service workers: https://bit.ly/CRA-PWA
12-
serviceWorker.unregister();
12+
serviceWorker.unregister()

src/react-app-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference types="react-scripts" />
1+
/// <reference types="@winify/react-scripts" />

src/serviceWorker.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,49 @@ const isLocalhost = Boolean(
1616
window.location.hostname === '[::1]' ||
1717
// 127.0.0.1/8 is considered localhost for IPv4.
1818
window.location.hostname.match(
19-
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20-
)
21-
);
19+
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
20+
),
21+
)
2222

2323
type Config = {
24-
onSuccess?: (registration: ServiceWorkerRegistration) => void;
25-
onUpdate?: (registration: ServiceWorkerRegistration) => void;
26-
};
24+
onSuccess?: (registration: ServiceWorkerRegistration) => void
25+
onUpdate?: (registration: ServiceWorkerRegistration) => void
26+
}
2727

2828
export function register(config?: Config) {
2929
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
3030
// The URL constructor is available in all browsers that support SW.
3131
const publicUrl = new URL(
3232
(process as { env: { [key: string]: string } }).env.PUBLIC_URL,
33-
window.location.href
34-
);
33+
window.location.href,
34+
)
3535
if (publicUrl.origin !== window.location.origin) {
3636
// Our service worker won't work if PUBLIC_URL is on a different origin
3737
// from what our page is served on. This might happen if a CDN is used to
3838
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
39-
return;
39+
return
4040
}
4141

4242
window.addEventListener('load', () => {
43-
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
43+
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
4444

4545
if (isLocalhost) {
4646
// This is running on localhost. Let's check if a service worker still exists or not.
47-
checkValidServiceWorker(swUrl, config);
47+
checkValidServiceWorker(swUrl, config)
4848

4949
// Add some additional logging to localhost, pointing developers to the
5050
// service worker/PWA documentation.
5151
navigator.serviceWorker.ready.then(() => {
5252
console.log(
5353
'This web app is being served cache-first by a service ' +
54-
'worker. To learn more, visit https://bit.ly/CRA-PWA'
55-
);
56-
});
54+
'worker. To learn more, visit https://bit.ly/CRA-PWA',
55+
)
56+
})
5757
} else {
5858
// Is not localhost. Just register service worker
59-
registerValidSW(swUrl, config);
59+
registerValidSW(swUrl, config)
6060
}
61-
});
61+
})
6262
}
6363
}
6464

@@ -67,9 +67,9 @@ function registerValidSW(swUrl: string, config?: Config) {
6767
.register(swUrl)
6868
.then(registration => {
6969
registration.onupdatefound = () => {
70-
const installingWorker = registration.installing;
70+
const installingWorker = registration.installing
7171
if (installingWorker == null) {
72-
return;
72+
return
7373
}
7474
installingWorker.onstatechange = () => {
7575
if (installingWorker.state === 'installed') {
@@ -79,65 +79,65 @@ function registerValidSW(swUrl: string, config?: Config) {
7979
// content until all client tabs are closed.
8080
console.log(
8181
'New content is available and will be used when all ' +
82-
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
83-
);
82+
'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
83+
)
8484

8585
// Execute callback
8686
if (config && config.onUpdate) {
87-
config.onUpdate(registration);
87+
config.onUpdate(registration)
8888
}
8989
} else {
9090
// At this point, everything has been precached.
9191
// It's the perfect time to display a
9292
// "Content is cached for offline use." message.
93-
console.log('Content is cached for offline use.');
93+
console.log('Content is cached for offline use.')
9494

9595
// Execute callback
9696
if (config && config.onSuccess) {
97-
config.onSuccess(registration);
97+
config.onSuccess(registration)
9898
}
9999
}
100100
}
101-
};
102-
};
101+
}
102+
}
103103
})
104104
.catch(error => {
105-
console.error('Error during service worker registration:', error);
106-
});
105+
console.error('Error during service worker registration:', error)
106+
})
107107
}
108108

109109
function checkValidServiceWorker(swUrl: string, config?: Config) {
110110
// Check if the service worker can be found. If it can't reload the page.
111111
fetch(swUrl)
112112
.then(response => {
113113
// Ensure service worker exists, and that we really are getting a JS file.
114-
const contentType = response.headers.get('content-type');
114+
const contentType = response.headers.get('content-type')
115115
if (
116116
response.status === 404 ||
117117
(contentType != null && contentType.indexOf('javascript') === -1)
118118
) {
119119
// No service worker found. Probably a different app. Reload the page.
120120
navigator.serviceWorker.ready.then(registration => {
121121
registration.unregister().then(() => {
122-
window.location.reload();
123-
});
124-
});
122+
window.location.reload()
123+
})
124+
})
125125
} else {
126126
// Service worker found. Proceed as normal.
127-
registerValidSW(swUrl, config);
127+
registerValidSW(swUrl, config)
128128
}
129129
})
130130
.catch(() => {
131131
console.log(
132-
'No internet connection found. App is running in offline mode.'
133-
);
134-
});
132+
'No internet connection found. App is running in offline mode.',
133+
)
134+
})
135135
}
136136

137137
export function unregister() {
138138
if ('serviceWorker' in navigator) {
139139
navigator.serviceWorker.ready.then(registration => {
140-
registration.unregister();
141-
});
140+
registration.unregister()
141+
})
142142
}
143143
}

src/stories/index.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)