Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.

Commit c700a54

Browse files
authored
refactor: refactor code (#36)
* refactor: 💡 refactor language imports * refactor: refactor linter errors * ci(travis): upgrade node version
1 parent f54624f commit c700a54

24 files changed

+13019
-14323
lines changed

.eslintrc.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
parser: 'babel-eslint',
3+
extends: ['plugin:react/recommended', 'plugin:prettier/recommended'],
4+
parserOptions: {
5+
ecmaVersion: 2018,
6+
sourceType: 'module',
7+
ecmaFeatures: {
8+
jsx: true,
9+
},
10+
},
11+
rules: {
12+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
13+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
14+
},
15+
settings: {
16+
react: {
17+
version: 'detect',
18+
},
19+
},
20+
};

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- 8
4+
- 10
55
cache:
66
bundle: true
77
directories:
@@ -13,4 +13,4 @@ after_success:
1313
- git config --global user.email "[email protected]"
1414
- git remote rm origin
1515
- git remote add origin https://umutcanbolat:${GITHUB_TOKEN}@github.com/umutcanbolat/instant-username-search.git
16-
- test $TRAVIS_BRANCH = "master" && npm run deploy
16+
- test $TRAVIS_BRANCH = "master" && npm run deploy

commitlint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

package-lock.json

-13,993
This file was deleted.

package.json

+46-8
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,58 @@
1818
"test": "react-scripts test",
1919
"eject": "react-scripts eject",
2020
"predeploy": "npm run build",
21-
"deploy": "gh-pages -d build"
21+
"deploy": "gh-pages -d build",
22+
"commit": "git-cz",
23+
"release": "standard-version",
24+
"lint": "eslint --ext .js,.jsx src/"
2225
},
2326
"eslintConfig": {
2427
"extends": "react-app"
2528
},
26-
"browserslist": [
27-
">0.2%",
28-
"not dead",
29-
"not ie <= 11",
30-
"not op_mini all"
31-
],
29+
"browserslist": {
30+
"production": [
31+
">0.2%",
32+
"not dead",
33+
"not op_mini all"
34+
],
35+
"development": [
36+
"last 1 chrome version",
37+
"last 1 firefox version",
38+
"last 1 safari version"
39+
]
40+
},
41+
"devDependencies": {
42+
"@commitlint/cli": "^8.1.0",
43+
"@commitlint/config-conventional": "^8.1.0",
44+
"commitizen": "^4.0.3",
45+
"cz-conventional-changelog": "^3.0.2",
46+
"eslint": "^6.2.2",
47+
"eslint-config-prettier": "^6.1.0",
48+
"eslint-plugin-prettier": "^3.1.0",
49+
"eslint-plugin-react": "^7.14.3",
50+
"husky": "^3.0.4",
51+
"lint-staged": "^9.2.4",
52+
"prettier": "^1.18.2"
53+
},
54+
"husky": {
55+
"hooks": {
56+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
57+
"pre-commit": "lint-staged"
58+
}
59+
},
60+
"config": {
61+
"commitizen": {
62+
"path": "./node_modules/cz-conventional-changelog"
63+
}
64+
},
65+
"lint-staged": {
66+
"*.js": [
67+
"eslint --fix",
68+
"git add"
69+
]
70+
},
3271
"description": "👤 Search for the availability of your username on more than 100 social media sites",
3372
"main": "index.js",
34-
"devDependencies": {},
3573
"repository": {
3674
"type": "git",
3775
"url": "git+https://github.com/instant-username-search/instant-username-search.git"

src/App.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './components/App';
4-
import { BrowserRouter as Router, Route } from "react-router-dom";
4+
import { BrowserRouter as Router, Route } from 'react-router-dom';
55

66
it('renders without crashing', () => {
77
const div = document.createElement('div');
88
ReactDOM.render(
99
<Router>
1010
<Route path="/:lang/" exact component={App} />
1111
</Router>,
12-
div);
12+
div,
13+
);
1314
ReactDOM.unmountComponentAtNode(div);
1415
});

src/components/App.js

+10-48
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,26 @@
1+
/* eslint-disable react/prop-types */
2+
/* eslint-disable react/no-deprecated */
13
import React, { Component } from 'react';
24
import { debounce } from 'debounce';
5+
import { IntlProvider, addLocaleData } from 'react-intl';
36
import Search from './Search';
47
import Results from './Results';
58
import Footer from './Footer';
69
import Privacy from './Privacy';
710
import Terms from './Terms';
811
import LandingPage from './Landing';
912

10-
import { IntlProvider, addLocaleData } from 'react-intl';
11-
import {
12-
locale_ca,
13-
locale_de,
14-
locale_en,
15-
locale_es,
16-
locale_fr,
17-
locale_ru,
18-
locale_tr,
19-
locale_uk,
20-
locale_zh,
21-
} from '../translations/locales';
22-
import {
23-
messages_ca,
24-
messages_de,
25-
messages_en,
26-
messages_es,
27-
messages_fr,
28-
messages_ru,
29-
messages_tr,
30-
messages_uk,
31-
messages_zh,
32-
} from '../translations';
13+
import locales from '../translations/locales';
14+
import translations from '../translations';
3315

34-
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
16+
import 'antd/dist/antd.css';
3517
import '../styles/App.css';
3618

3719
window.apiUrl = process.env.REACT_APP_API_URL;
3820
const checkEndpoint = window.apiUrl + 'check';
3921
const initSearchEndpoint = window.apiUrl + 'initSearch';
4022

41-
addLocaleData([
42-
...locale_en,
43-
...locale_de,
44-
...locale_tr,
45-
...locale_es,
46-
...locale_ca,
47-
...locale_fr,
48-
...locale_uk,
49-
...locale_ru,
50-
...locale_zh,
51-
]);
52-
const messages = {
53-
de: messages_de,
54-
en: messages_en,
55-
tr: messages_tr,
56-
ca: messages_ca,
57-
es: messages_es,
58-
fr: messages_fr,
59-
uk: messages_uk,
60-
ru: messages_ru,
61-
zh: messages_zh,
62-
};
23+
addLocaleData(locales);
6324

6425
// AbortController and signal to cancel fetch requests
6526
var controller;
@@ -79,7 +40,8 @@ class App extends Component {
7940
}
8041

8142
reset = () => {
82-
this.setState(initialState);
43+
this.setState({ ...initialState, language: this.state.language });
44+
this.componentWillUnmount();
8345
this.componentDidMount();
8446
};
8547

@@ -247,7 +209,7 @@ class App extends Component {
247209
}
248210

249211
return (
250-
<IntlProvider locale={this.state.language} messages={messages[this.state.language]}>
212+
<IntlProvider locale={this.state.language} messages={translations[this.state.language]}>
251213
<div>
252214
<div className="jumbotron">
253215
<div className="container" id="jumbotron">

src/components/Privacy.js

+42-15
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,45 @@ import React from 'react';
22
import '../styles/SubPage.css';
33

44
export default function Privacy() {
5-
6-
return (
7-
<div className="sub">
8-
<h1>Privacy Policy</h1>
9-
<p>Your privacy is important to us. It is Instant Username Search's policy to respect your privacy regarding any information we may collect from you across our website, <a href="https://instantusername.com">https://instantusername.com</a>, and other sites we own and operate.</p>
10-
<p>We only ask for personal information when we truly need it to provide a service to you. We collect it by fair and lawful means, with your knowledge and consent. We also let you know why we’re collecting it and how it will be used.</p>
11-
<p>We only retain collected information for as long as necessary to provide you with your requested service. What data we store, we’ll protect within commercially acceptable means to prevent loss and theft, as well as unauthorised access, disclosure, copying, use or modification.</p>
12-
<p>We don’t share any personally identifying information publicly or with third-parties, except when required to by law.</p>
13-
<p>Our website may link to external sites that are not operated by us. Please be aware that we have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies.</p>
14-
<p>You are free to refuse our request for your personal information, with the understanding that we may be unable to provide you with some of your desired services.</p>
15-
<p>Your continued use of our website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how we handle user data and personal information, feel free to contact us.</p>
16-
<p>This policy is effective as of 6 May 2019.</p>
17-
</div>
18-
);
19-
}
5+
return (
6+
<div className="sub">
7+
<h1>Privacy Policy</h1>
8+
<p>
9+
Your privacy is important to us. It is Instant Username Search's policy to respect your
10+
privacy regarding any information we may collect from you across our website,{' '}
11+
<a href="https://instantusername.com">https://instantusername.com</a>, and other sites we
12+
own and operate.
13+
</p>
14+
<p>
15+
We only ask for personal information when we truly need it to provide a service to you. We
16+
collect it by fair and lawful means, with your knowledge and consent. We also let you know
17+
why we’re collecting it and how it will be used.
18+
</p>
19+
<p>
20+
We only retain collected information for as long as necessary to provide you with your
21+
requested service. What data we store, we’ll protect within commercially acceptable means to
22+
prevent loss and theft, as well as unauthorised access, disclosure, copying, use or
23+
modification.
24+
</p>
25+
<p>
26+
We don’t share any personally identifying information publicly or with third-parties, except
27+
when required to by law.
28+
</p>
29+
<p>
30+
Our website may link to external sites that are not operated by us. Please be aware that we
31+
have no control over the content and practices of these sites, and cannot accept
32+
responsibility or liability for their respective privacy policies.
33+
</p>
34+
<p>
35+
You are free to refuse our request for your personal information, with the understanding
36+
that we may be unable to provide you with some of your desired services.
37+
</p>
38+
<p>
39+
Your continued use of our website will be regarded as acceptance of our practices around
40+
privacy and personal information. If you have any questions about how we handle user data
41+
and personal information, feel free to contact us.
42+
</p>
43+
<p>This policy is effective as of 6 May 2019.</p>
44+
</div>
45+
);
46+
}

src/components/ResultCard.js

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import React, { Component } from "react";
2-
import { Card } from "antd";
3-
import { FormattedMessage } from "react-intl";
4-
import "../styles/ResultCard.css";
1+
import React, { Component } from 'react';
2+
import { Card } from 'antd';
3+
import { FormattedMessage } from 'react-intl';
4+
import '../styles/ResultCard.css';
55

66
const { Meta } = Card;
77

88
class ResultCard extends Component {
99
render() {
1010
if (this.props.loading) {
1111
return (
12-
<div className={"loading card"}>
12+
<div className={'loading card'}>
1313
<Card hoverable loading={true}></Card>
1414
</div>
1515
);
1616
} else if (this.props.ad) {
1717
return (
18-
<div className={"card ad"}>
18+
<div className={'card ad'}>
1919
<script
2020
async
2121
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
@@ -24,9 +24,9 @@ class ResultCard extends Component {
2424
<ins
2525
className="adsbygoogle"
2626
style={{
27-
display: "inlineBlock",
28-
width: "214px",
29-
minHeight: "93px"
27+
display: 'inlineBlock',
28+
width: '214px',
29+
minHeight: '93px',
3030
}}
3131
data-ad-client="ca-pub-2749239984003144"
3232
data-ad-slot="2583466004"
@@ -37,22 +37,16 @@ class ResultCard extends Component {
3737
} else {
3838
let classStatus, status;
3939
if (this.props.result.available) {
40-
classStatus = "available";
41-
status = (
42-
<FormattedMessage id="card.available" defaultMessage="Available" />
43-
);
40+
classStatus = 'available';
41+
status = <FormattedMessage id="card.available" defaultMessage="Available" />;
4442
} else {
45-
classStatus = "taken";
43+
classStatus = 'taken';
4644
status = <FormattedMessage id="card.taken" defaultMessage="Taken" />;
4745
}
4846

4947
return (
50-
<div className={"card " + classStatus}>
51-
<a
52-
href={this.props.result.url}
53-
target="_blank"
54-
rel="noopener noreferrer"
55-
>
48+
<div className={'card ' + classStatus}>
49+
<a href={this.props.result.url} target="_blank" rel="noopener noreferrer">
5650
<Card hoverable>
5751
<Meta title={this.props.result.service} description={status} />
5852
</Card>

0 commit comments

Comments
 (0)