Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 272f7ea

Browse files
committed
switch to eslint & prettier
1 parent 9d0c74e commit 272f7ea

20 files changed

+594
-99
lines changed

.editorconfig

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

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
},
6+
extends: ['eslint:recommended', 'plugin:react/recommended', 'react-app'],
7+
parser: '@typescript-eslint/parser',
8+
parserOptions: {
9+
ecmaFeatures: {
10+
jsx: true,
11+
},
12+
ecmaVersion: 12,
13+
sourceType: 'module',
14+
},
15+
plugins: ['react', 'react-hooks', 'prettier'],
16+
settings: { react: { version: '^15.0.0 || ^16.0.0' } },
17+
rules: {
18+
quotes: ['error', 'single'],
19+
semi: ['error', 'always'],
20+
'comma-dangle': ['error', 'always-multiline'],
21+
},
22+
};

.prettierrc

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

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to the "react-github-buttons" project will be documented in
77
- Update Dependencies
88
- Drop node 8
99
- remove tslint
10+
- switch to eslint & prettier
1011

1112
## [0.4.0] 2019-6-15
1213
### Added

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"test:watch": "react-scripts-ts test --env=jsdom",
3333
"build": "rollup -c",
3434
"start": "rollup -c -w",
35-
"prepare": "npm run build",
35+
"prepare": "yarn build",
3636
"predeploy": "cd example && npm install && npm run build",
3737
"deploy": "gh-pages -d example/build",
38-
"lint": "tslint **/src/**.{ts,tsx} --exclude **/node_modules/**"
38+
"lint": "eslint src"
3939
},
4040
"dependencies": {},
4141
"peerDependencies": {
@@ -50,10 +50,19 @@
5050
"@types/prop-types": "^15.7.1",
5151
"@types/react": "^16.3.13",
5252
"@types/react-dom": "^16.0.5",
53+
"@typescript-eslint/eslint-plugin": "^4.3.0",
54+
"@typescript-eslint/parser": "^4.3.0",
5355
"babel-core": "^6.26.3",
5456
"babel-runtime": "^6.26.0",
5557
"cross-env": "^7.0.2",
5658
"eslint": "^7.10.0",
59+
"eslint-config-react-app": "^5.2.1",
60+
"eslint-plugin-flowtype": "^5.2.0",
61+
"eslint-plugin-import": "^2.22.1",
62+
"eslint-plugin-jsx-a11y": "^6.3.1",
63+
"eslint-plugin-prettier": "^3.1.4",
64+
"eslint-plugin-react": "^7.21.3",
65+
"eslint-plugin-react-hooks": "^4.1.2",
5766
"gh-pages": "^3.1.0",
5867
"react-scripts-ts": "^3.1.0",
5968
"rollup": "^2.28.2",

src/__tests__/index.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { Fork, Sponsor, Star, UsedBy, Watch } from "../index";
1+
import { Fork, Sponsor, Star, UsedBy, Watch } from '../index';
22

3-
describe(">>> Exports required components", () => {
4-
it("+++ Fork is truthy", () => {
3+
describe('>>> Exports required components', () => {
4+
it('+++ Fork is truthy', () => {
55
expect(Fork).toBeTruthy();
66
});
77

8-
it("+++ Sponsor is truthy", () => {
8+
it('+++ Sponsor is truthy', () => {
99
expect(Sponsor).toBeTruthy();
1010
});
1111

12-
it("+++ Star is truthy", () => {
12+
it('+++ Star is truthy', () => {
1313
expect(Star).toBeTruthy();
1414
});
1515

16-
it("+++ UsedBy is truthy", () => {
16+
it('+++ UsedBy is truthy', () => {
1717
expect(UsedBy).toBeTruthy();
1818
});
1919

20-
it("+++ Watch is truthy", () => {
20+
it('+++ Watch is truthy', () => {
2121
expect(Watch).toBeTruthy();
2222
});
2323
});

src/fork.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* @function Fork
33
*/
4-
import * as PropTypes from "prop-types";
5-
import * as React from "react";
4+
import * as PropTypes from 'prop-types';
5+
import * as React from 'react';
66

7-
import GithubButton from "./lib/githubButton";
7+
import GithubButton from './lib/githubButton';
88

99
export interface IPropTypes {
1010
owner: string;
@@ -30,14 +30,16 @@ export default class Fork extends React.Component<IPropTypes, IState> {
3030

3131
componentDidMount() {
3232
const { owner, repo } = this.props;
33-
fetch(`https://api.github.com/repos/${owner}/${repo}`).then((res) => res.json()).then((res) => {
34-
this.setState({ forks_count: res.forks_count });
35-
});
33+
fetch(`https://api.github.com/repos/${owner}/${repo}`)
34+
.then((res) => res.json())
35+
.then((res) => {
36+
this.setState({ forks_count: res.forks_count });
37+
});
3638
}
3739

3840
render() {
3941
// const { owner, repo } = this.props;
4042
const { forks_count } = this.state;
41-
return <GithubButton variant="fork" count={forks_count} { ...this.props } />;
43+
return <GithubButton variant="fork" count={forks_count} {...this.props} />;
4244
}
4345
}

src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import Fork from "./fork";
2-
import Sponsor from "./sponsor";
3-
import Star from "./star";
4-
import UsedBy from "./usedBy";
5-
import Watch from "./watch";
1+
import Fork from './fork';
2+
import Sponsor from './sponsor';
3+
import Star from './star';
4+
import UsedBy from './usedBy';
5+
import Watch from './watch';
66

7-
export { Fork, Sponsor, Star, UsedBy, Watch };
7+
export {
8+
Fork, Sponsor, Star, UsedBy, Watch,
9+
};

src/lib/githubButton.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
22
* @function GithubButton
33
*/
4-
import * as PropTypes from "prop-types";
5-
import * as React from "react";
4+
import * as PropTypes from 'prop-types';
5+
import * as React from 'react';
66

7-
import classes from "../styles.css";
7+
import classes from '../styles.css';
88

9-
import ForkIcon from "./icons/forkIcon";
10-
import StarIcon from "./icons/starIcon";
11-
import WatchIcon from "./icons/watchIcon";
9+
import ForkIcon from './icons/forkIcon';
10+
import StarIcon from './icons/starIcon';
11+
import WatchIcon from './icons/watchIcon';
1212
import UsedByIcon from './icons/usedByIcon';
1313
import SponsorIcon from './icons/sponsorIcon';
1414

@@ -28,38 +28,38 @@ function getDataForVariant(
2828
let btnTitle: string;
2929
let label: string;
3030
let countUrl: string;
31-
if (variant === "star") {
32-
title = "Star";
31+
if (variant === 'star') {
32+
title = 'Star';
3333
btnTitle = `Star ${owner}/${repo}`;
3434
label = `${count} users starred this repository`;
3535
countUrl = `https://github.com/${owner}/${repo}/stargazers`;
3636
return { title, btnTitle, label, countUrl, Icon: StarIcon };
37-
} else if (variant === "fork") {
38-
title = "Fork";
37+
} else if (variant === 'fork') {
38+
title = 'Fork';
3939
btnTitle = `Fork your own copy of ${owner}/${repo} to your account`;
4040
label = `${count} users forked this repository`;
4141
countUrl = `https://github.com/${owner}/${repo}/network/members`;
4242
return { title, btnTitle, label, countUrl, Icon: ForkIcon };
43-
} else if (variant === "watch") {
44-
title = "Watch";
45-
btnTitle = "";
43+
} else if (variant === 'watch') {
44+
title = 'Watch';
45+
btnTitle = '';
4646
label = `${count} users are watching this repository`;
4747
countUrl = `https://github.com/${owner}/${repo}/watchers`;
4848
return { title, btnTitle, label, countUrl, Icon: WatchIcon };
49-
} else if (variant === "usedby") {
50-
title = "Used by";
51-
btnTitle = "";
49+
} else if (variant === 'usedby') {
50+
title = 'Used by';
51+
btnTitle = '';
5252
label = `${count} repositories depend on this package`;
5353
countUrl = `https://github.com/${owner}/${repo}/network/dependents`;
5454
return { title, btnTitle, label, countUrl, Icon: UsedByIcon };
55-
} else if (variant === "sponsor") {
56-
title = "Sponsor";
55+
} else if (variant === 'sponsor') {
56+
title = 'Sponsor';
5757
btnTitle = `Sponsor ${owner}/${repo}`;
58-
label = "";
59-
countUrl = "";
58+
label = '';
59+
countUrl = '';
6060
return { title, btnTitle, label, countUrl, Icon: SponsorIcon };
6161
}
62-
throw new Error("Invalid Variant, supply one of [star, fork, watch, usedby, sponsor]");
62+
throw new Error('Invalid Variant, supply one of [star, fork, watch, usedby, sponsor]');
6363
}
6464

6565
export interface IPropTypes {
@@ -74,7 +74,7 @@ export default function GithubButton(props: IPropTypes) {
7474
const { owner, repo, variant, count, showCount } = props;
7575
const { title, btnTitle, label, countUrl, Icon } = getDataForVariant(variant, count, owner, repo);
7676

77-
const inlineStyle = showCount ? {} : { borderRadius: ".25em" };
77+
const inlineStyle = showCount ? {} : { borderRadius: '.25em' };
7878

7979
return (
8080
<div className={classes.root}>
@@ -99,7 +99,7 @@ GithubButton.propTypes = {
9999
count: PropTypes.number,
100100
owner: PropTypes.string.isRequired,
101101
repo: PropTypes.string.isRequired,
102-
variant: PropTypes.oneOf(["star", "fork", "watch", "usedby", "sponsor"]),
102+
variant: PropTypes.oneOf(['star', 'fork', 'watch', 'usedby', 'sponsor']),
103103
showCount: PropTypes.bool,
104104
};
105105

src/lib/icons/forkIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as React from "react";
2-
import classes from "../../styles.css";
1+
import * as React from 'react';
2+
import classes from '../../styles.css';
33

44
export default function ForkIcon() {
55
return (

0 commit comments

Comments
 (0)