Skip to content

Commit 488be5d

Browse files
committed
feat: add prettier
2 parents 62319bb + 5f7082e commit 488be5d

9 files changed

+97
-29
lines changed

.github/workflows/format.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Formatting Check
2+
3+
on: [push]
4+
5+
jobs:
6+
formatting:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- name: Use Node 16.2.0
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: 16.2.0
15+
16+
- name: Cache Node.js modules
17+
uses: actions/cache@v1
18+
with:
19+
path: ~/.yarn
20+
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
21+
restore-keys: |
22+
${{ runner.OS }}-node-
23+
${{ runner.OS }}-
24+
- name: Install dependencies
25+
run: yarn install --frozen-lockfile
26+
27+
- name: Formatting
28+
run: yarn run format:check

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn run pre-commit

.prettierrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
semi: true,
3+
arrowParens: "avoid",
4+
tabWidth: 2,
5+
singleQuote: false,
6+
};

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ NextJS and React Snippets with TypeScript support as well!🚀
4040

4141
### JavaScript
4242

43+
<<<<<<< HEAD
4344
1. `nssr` (Get Server Side Props Next.js)
45+
=======
46+
1. `nssr` (Next.js Get Server Side Props Typescript)
47+
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
4448

4549
```jsx
4650
export const getServerSideProps = async (context) => {
@@ -50,7 +54,11 @@ NextJS and React Snippets with TypeScript support as well!🚀
5054
};
5155
```
5256

57+
<<<<<<< HEAD
5358
2. `nssg` (Get Static Props Next.js)
59+
=======
60+
2. `nssg` (Next.js Get Static Props Typescript)
61+
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
5462

5563
```jsx
5664
export const getStaticProps = async (context) => {
@@ -62,15 +70,23 @@ NextJS and React Snippets with TypeScript support as well!🚀
6270

6371
### TypeScript
6472

73+
<<<<<<< HEAD
6574
1. `nssrt` (Get Server Side Props Next.js)
75+
=======
76+
1. `nssrt` (Next.js Get Server Side Props Typescript)
77+
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
6678

6779
```tsx
6880
export const getServerSideProps: GetServerSideProps = async (context) => {
6981
return { props: {} };
7082
};
7183
```
7284

85+
<<<<<<< HEAD
7386
2. `nssgt` (Get Static Props Next.js)
87+
=======
88+
2. `nssgt` (Next.js Get Static Props Typescript)
89+
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
7490

7591
```tsx
7692
export const getStaticProps: getStaticProps = async (context) => {
@@ -86,7 +102,11 @@ NextJS and React Snippets with TypeScript support as well!🚀
86102
};
87103
```
88104

105+
<<<<<<< HEAD
89106
3) `npaget` (NextPage component with NextPage type)
107+
=======
108+
3) `npt` (Next.js Page Typescript)
109+
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
90110

91111
```tsx
92112
import type { NextPage } from "next";
@@ -96,7 +116,11 @@ NextJS and React Snippets with TypeScript support as well!🚀
96116
export default Page;
97117
```
98118

119+
<<<<<<< HEAD
99120
4) `nct` (Next JS Component with NextComponentType and Props)
121+
=======
122+
4) `nct` (Next.js Component Typescript)
123+
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
100124

101125
```tsx
102126
import type { NextComponentType, NextPageContext } from "next";

package.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
"vscode": "^1.64.0"
88
},
99
"scripts": {
10-
"format": "prettier --write \"{components,code}/**/*.{js,jsx,ts,tsx}\"",
11-
"format:check": "prettier --check \"{components,code}/**/*.{js,jsx,ts,tsx}\""
10+
"prepare": "husky install",
11+
"pre-commit": "yarn run format && yarn run lint && git add -A .",
12+
"format": "prettier --write \"{code,snippets}/**/*.{js,jsx,ts,tsx,json,md}\"",
13+
"format:check": "prettier --check \"{code,snippets}/**/*.{js,jsx,ts,tsx,json,md}\"",
14+
"release": "standard-version",
15+
"release:minor": "standard-version --release-as minor",
16+
"release:patch": "standard-version --release-as patch",
17+
"release:major": "standard-version --release-as major"
1218
},
1319
"categories": [
1420
"Snippets"
@@ -40,4 +46,4 @@
4046
"devDependencies": {
4147
"husky": "^7.0.4"
4248
}
43-
}
49+
}

snippets/next-javascript.code-snippets snippets/next-javascript.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"};",
1010
""
1111
],
12-
"description": "Get Server Side Props Next.js"
12+
"description": "Next.js Get Server Side Props Typescript"
1313
},
1414
"ssg": {
1515
"prefix": "nssg",
@@ -21,6 +21,6 @@
2121
"};",
2222
""
2323
],
24-
"description": "Get Static Props Next.js"
24+
"description": "Next.js Get Static Props Typescript"
2525
}
26-
}
26+
}

snippets/next-typescript.code-snippets snippets/next-typescript.json

+21-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"};",
1010
""
1111
],
12-
"description": "Get Server Side Props Next.js"
12+
"description": "Next.js Get Server Side Props Typescript"
1313
},
1414
"nssgt": {
1515
"prefix": "nssgt",
@@ -21,10 +21,10 @@
2121
"};",
2222
""
2323
],
24-
"description": "Get Static Props Next.js"
24+
"description": "Next.js Get Static Props Typescript"
2525
},
26-
"npaget": {
27-
"prefix": "npaget",
26+
"npt": {
27+
"prefix": "npt",
2828
"body": [
2929
"import type { NextPage } from \"next\";",
3030
"",
@@ -37,35 +37,35 @@
3737
"",
3838
"export default ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}"
3939
],
40-
"description": "NextPage component with NextPage type"
41-
},
42-
"ngip": {
40+
"description": "Next.js Page Typescript"
41+
},
42+
"ngip": {
4343
"prefix": "ngip",
4444
"body": [
4545
"${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}.getInitialProps = async context => {",
4646
" return {",
4747
" ",
4848
" };",
4949
"};",
50-
""
50+
""
5151
],
52-
"description": "Get Initial Props in Next.js"
53-
},
54-
"nct": {
55-
"prefix": "nct",
56-
"body": [
57-
"import type { NextComponentType, NextPageContext } from \"next\";",
58-
"interface Props {}",
59-
"const ${1:${TM_FILENAME_BASE}}: NextComponentType<NextPageContext, {}, Props> = (",
52+
"description": "Next.js Get Initial Props"
53+
},
54+
"nct": {
55+
"prefix": "nct",
56+
"body": [
57+
"import type { NextComponentType, NextPageContext } from \"next\";",
58+
"interface Props {}",
59+
"const ${1:${TM_FILENAME_BASE}}: NextComponentType<NextPageContext, {}, Props> = (",
6060
" props: Props,",
6161
") => {",
62-
" return (",
62+
" return (",
6363
" <div></div>",
6464
" )",
65-
"}",
65+
"}",
6666
"",
6767
"export default ${1:${TM_FILENAME_BASE}}"
68-
],
69-
"description": "Next JS Component with NextComponentType and Props"
70-
}
68+
],
69+
"description": "Next.js Component Typescript"
70+
}
7171
}

snippets/react-javascript.code-snippets snippets/react-javascript.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
],
2727
"description": "React Functional Component"
2828
}
29-
}
29+
}

snippets/react-typescript.code-snippets snippets/react-typescript.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
],
3030
"description": "React Functional Component with Types"
3131
}
32-
}
32+
}

0 commit comments

Comments
 (0)