Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 8e352a2

Browse files
authored
Add pre-commit hooks and lints (#26)
* Add initial style and husky checks * Improve lint configs * Add install hook for husky * Fix format with prettier
1 parent c1bc840 commit 8e352a2

26 files changed

+568
-420
lines changed

‎.eslintrc.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2-
"extends": "next/core-web-vitals",
3-
"rules": {
4-
"@next/next/no-img-element": 0,
5-
"react/no-unescaped-entities": 0,
6-
"react/display-name": 0,
7-
"import/no-anonymous-default-export": 0,
8-
"react-hooks/exhaustive-deps": "warn",
9-
"react-hooks/rules-of-hooks": "error",
10-
"semi": ["error", "never"],
11-
"indent": ["error", "tab"],
12-
"quotes": [2, "double", { "avoidEscape": true }]
13-
}
14-
}
2+
"extends": ["next/core-web-vitals", "next", "prettier"],
3+
"env": {
4+
"browser": true,
5+
"es2021": true
6+
},
7+
"plugins": ["prettier"],
8+
"rules": {
9+
"@next/next/no-img-element": 0,
10+
"react/no-unescaped-entities": 0,
11+
"react/display-name": 0,
12+
"import/no-anonymous-default-export": 0,
13+
"react-hooks/exhaustive-deps": "warn",
14+
"react-hooks/rules-of-hooks": "error",
15+
"prettier/prettier": "error"
16+
}
17+
}

‎.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install lint-staged

‎.prettierignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
node_modules
2+
**/.next/**
3+
**/_next/**
4+
**/dist/**
5+
packages/next/bundles/webpack/packages/*.runtime.js
6+
packages/next/bundles/webpack/packages/lazy-compilation-*.js
7+
packages/next/compiled/**
8+
packages/react-refresh-utils/**/*.js
9+
packages/react-refresh-utils/**/*.d.ts
10+
packages/react-dev-overlay/lib/**
11+
**/__tmp__/**
12+
lerna.json
13+
.github/actions/next-stats-action/.work
14+
.github/actions/issue-validator/index.mjs
15+
packages/next-swc/crates/**/*
16+
packages/next-swc/target/**/*
17+
packages/next-swc/native/**/*
18+
packages/next-codemod/transforms/__testfixtures__/**/*
19+
packages/next-codemod/transforms/__tests__/**/*
20+
packages/next-codemod/**/*.js
21+
packages/next-codemod/**/*.d.ts
22+
packages/next-env/**/*.d.ts
23+
test-timings.json
24+
test/**/out/**
25+
bench/nested-deps/pages/**/*
26+
bench/nested-deps/components/**/*
27+
pnpm-lock.yaml
28+
**/convex/_generated/**
29+
build
30+
.github

‎.prettierrc

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

‎.prettierrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
bracketSpacing: true,
3+
bracketSameLine: true,
4+
singleQuote: false,
5+
trailingComma: "none",
6+
semi: false,
7+
tabWidth: 4
8+
}

‎README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,44 @@
99
<img src=".github/splash.png">
1010
</p>
1111

12-
1312
## Online
13+
1414
You can find and bookmark the online version from [git-cheats.vercel.app](https://git-cheats.vercel.app)
1515

1616
## Local
17+
1718
1. Clone this repository
1819
2. Run `yarn` to install dependencies
1920
3. Run `yarn dev` to start server
2021

2122
## How To Contribute
23+
2224
Please feel free to contribute any way you can. Just keep in mind that you should pay attention to [CONTRIBUTE.md](.github/CONTRIBUTING.md) before contributing.
2325

2426
That being said, you can;
25-
* Create issues for feature requests and issues
26-
* Create pull requests for any fixes / additions
27-
* Create pull requests for localizations
27+
28+
- Create issues for feature requests and issues
29+
- Create pull requests for any fixes / additions
30+
- Create pull requests for localizations
2831

2932
## Technology
30-
- Hosted on [Vercel](https://vercel.com/) &hearts;
31-
- [Bootstrap](https://getbootstrap.com/)
32-
- [Next.js](https://nextjs.org/)
33-
- [React](https://reactjs.org/)
34-
- [SWR](https://swr.vercel.app/)
3533

36-
You can find the rest in [package.json](package.json)
34+
- Hosted on [Vercel](https://vercel.com/) &hearts;
35+
- [Bootstrap](https://getbootstrap.com/)
36+
- [Next.js](https://nextjs.org/)
37+
- [React](https://reactjs.org/)
38+
- [SWR](https://swr.vercel.app/)
3739

40+
You can find the rest in [package.json](package.json)
3841

3942
## License
43+
4044
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
4145

4246
## Other Useful Projects
47+
4348
If you think there should be more, please create an issue labeled as `enhancement` and give direct link to the project.
44-
* [Git Init](https://pel-daniel.github.io/git-init) - Great learning tool for learning how to use commands
45-
* [Git - The Simple Guide](https://rogerdudler.github.io/git-guide) - Simple guide for getting started with git
46-
* [Learn Git Branching](https://learngitbranching.js.org) - Learn how to use branches properly
49+
50+
- [Git Init](https://pel-daniel.github.io/git-init) - Great learning tool for learning how to use commands
51+
- [Git - The Simple Guide](https://rogerdudler.github.io/git-guide) - Simple guide for getting started with git
52+
- [Learn Git Branching](https://learngitbranching.js.org) - Learn how to use branches properly

‎components/Card/index.js

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,69 @@ import Code from "../Code"
44
import "@fontsource/rubik"
55
import { BsFillArrowUpRightSquareFill } from "react-icons/bs"
66

7-
const Card = ({
8-
data,
9-
query,
10-
isAdvanced
11-
}) => {
12-
const [isHidden, setHidden] = useState(false)
7+
const Card = ({ data, query, isAdvanced }) => {
8+
const [isHidden, setHidden] = useState(false)
139

14-
let link = "https://git-scm.com/docs/git-" + data.name
15-
let category = data.category.toLowerCase()
10+
let link = "https://git-scm.com/docs/git-" + data.name
11+
let category = data.category.toLowerCase()
1612

17-
useEffect(() => {
18-
if (!isAdvanced && data.isAdvanced) {
19-
setHidden(true)
20-
return
21-
}
22-
23-
if (query) {
24-
setHidden(!data.keywords.includes(query))
25-
} else {
26-
setHidden(false)
27-
}
28-
}, [query, isAdvanced, data.keywords, data.isAdvanced]), [isHidden]
13+
useEffect(() => {
14+
if (!isAdvanced && data.isAdvanced) {
15+
setHidden(true)
16+
return
17+
}
2918

30-
return (
31-
<div className={isHidden ? "card hidden" : "card"}>
32-
<div className={`mh-100 card-accent ${category}`}></div>
33-
<div className="card-content">
34-
<div className="card-body">
35-
<div className="row g-0 text-center">
36-
<div className="col-sm-6 col-md-8">
37-
<h1 className="card-title">
38-
<Link href={link} className="documentation-link" target="_blank" rel="noopener noreferrer nofollow">
39-
{data.name}
40-
<BsFillArrowUpRightSquareFill className="documentation-icon"/>
41-
</Link>
42-
</h1>
43-
</div>
44-
<div className="col-6 col-md-4">
45-
<p className={`card-category ${category}`}>{data.category}</p>
46-
</div>
47-
</div>
48-
<p className="card-description">{data.description}</p>
49-
<h5 className="card-usage">Usage:</h5>
50-
<div>
51-
{data.usage.map((usage, index) => {
52-
{
53-
return (
54-
<Code key={index} usage={usage} showAdvanced={isAdvanced}/>
55-
)
56-
}
57-
})}
58-
</div>
59-
</div>
60-
</div>
61-
</div>
62-
)
19+
if (query) {
20+
setHidden(!data.keywords.includes(query))
21+
} else {
22+
setHidden(false)
23+
}
24+
}, [query, isAdvanced, data.keywords, data.isAdvanced]),
25+
[isHidden]
26+
27+
return (
28+
<div className={isHidden ? "card hidden" : "card"}>
29+
<div className={`mh-100 card-accent ${category}`}></div>
30+
<div className="card-content">
31+
<div className="card-body">
32+
<div className="row g-0 text-center">
33+
<div className="col-sm-6 col-md-8">
34+
<h1 className="card-title">
35+
<Link
36+
href={link}
37+
className="documentation-link"
38+
target="_blank"
39+
rel="noopener noreferrer nofollow">
40+
{data.name}
41+
<BsFillArrowUpRightSquareFill className="documentation-icon" />
42+
</Link>
43+
</h1>
44+
</div>
45+
<div className="col-6 col-md-4">
46+
<p className={`card-category ${category}`}>
47+
{data.category}
48+
</p>
49+
</div>
50+
</div>
51+
<p className="card-description">{data.description}</p>
52+
<h5 className="card-usage">Usage:</h5>
53+
<div>
54+
{data.usage.map((usage, index) => {
55+
{
56+
return (
57+
<Code
58+
key={index}
59+
usage={usage}
60+
showAdvanced={isAdvanced}
61+
/>
62+
)
63+
}
64+
})}
65+
</div>
66+
</div>
67+
</div>
68+
</div>
69+
)
6370
}
6471

6572
export default Card

‎components/Code/index.js

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,33 @@ import React, { useEffect, useState } from "react"
22
import { IoCopy } from "react-icons/io5"
33
import "@fontsource/fira-code"
44

5-
const CodeBlock = ({
6-
usage,
7-
showAdvanced
8-
}) => {
9-
const [isHidden, setHidden] = useState(false)
10-
const code = "git " + usage.code
5+
const CodeBlock = ({ usage, showAdvanced }) => {
6+
const [isHidden, setHidden] = useState(false)
7+
const code = "git " + usage.code
118

12-
useEffect(() => {
13-
setHidden(!showAdvanced && usage.isAdvanced)
14-
}, [showAdvanced, usage.isAdvanced])
9+
useEffect(() => {
10+
setHidden(!showAdvanced && usage.isAdvanced)
11+
}, [showAdvanced, usage.isAdvanced])
1512

16-
const handleCopy = () => {
17-
navigator.clipboard.writeText("git " + usage.code)
18-
}
13+
const handleCopy = () => {
14+
navigator.clipboard.writeText("git " + usage.code)
15+
}
1916

20-
return (
21-
<div className= {isHidden ? "code-block hidden" : "code-block"}>
22-
<pre>
23-
<div className="code-row row g-0">
24-
<code className="col d-sm-flex">
25-
{code}
26-
</code>
27-
<button className="btn btn-default col-md-1" onClick={handleCopy}>
28-
<IoCopy/>
29-
</button>
30-
</div>
31-
</pre>
32-
<p className="code-description">{usage.description}</p>
33-
</div>
34-
)
17+
return (
18+
<div className={isHidden ? "code-block hidden" : "code-block"}>
19+
<pre>
20+
<div className="code-row row g-0">
21+
<code className="col d-sm-flex">{code}</code>
22+
<button
23+
className="btn btn-default col-md-1"
24+
onClick={handleCopy}>
25+
<IoCopy />
26+
</button>
27+
</div>
28+
</pre>
29+
<p className="code-description">{usage.description}</p>
30+
</div>
31+
)
3532
}
3633

37-
export default CodeBlock
34+
export default CodeBlock

‎components/Footer/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import React from "react"
22
import Link from "next/link"
33

44
const Footer = () => {
5-
return (
6-
<div className="footer wh-100">
7-
<p>Made with <span>&hearts;</span> by <Link href="https://github.com/excalith">excalith</Link></p>
8-
</div>
9-
)
5+
return (
6+
<div className="footer wh-100">
7+
<p>
8+
Made with <span>&hearts;</span> by{" "}
9+
<Link href="https://github.com/excalith">excalith</Link>
10+
</p>
11+
</div>
12+
)
1013
}
1114

1215
export default Footer

‎components/Loader/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import React from "react"
22
import HashLoader from "react-spinners/HashLoader"
33

44
const Loader = () => {
5-
return (
6-
<HashLoader className="position-absolute top-50 start-50 translate-middle" size="120px" color="#df8e1d" />
7-
)
5+
return (
6+
<HashLoader
7+
className="position-absolute top-50 start-50 translate-middle"
8+
size="120px"
9+
color="#df8e1d"
10+
/>
11+
)
812
}
913

1014
export default Loader

0 commit comments

Comments
 (0)