Skip to content

Commit caa7d1d

Browse files
committed
feat: upgrade to react 17
1 parent 4a7d44d commit caa7d1d

File tree

12 files changed

+146
-122
lines changed

12 files changed

+146
-122
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ root = true
44
end_of_line = lf
55
insert_final_newline = true
66

7-
[*.{js, jsx, ts, tsx}]
7+
[*.{ts, tsx}]
88
charset = utf-8
99
indent_style = space
1010
indent_size = 2
1111

1212
[Makefile]
13-
indent_style = tab
13+
indent_style = tab

.eslintrc

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,14 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"env": {
4-
"node": true,
5-
"browser": true,
6-
"es6": true,
7-
"jest": true
8-
},
92
"plugins": [
10-
"@typescript-eslint",
11-
"react",
12-
"import",
13-
"prettier",
14-
"react-hooks",
15-
"redux-saga"
3+
"prettier"
164
],
175
"extends": [
18-
"plugin:@typescript-eslint/recommended",
19-
"plugin:react/recommended",
20-
"plugin:redux-saga/recommended",
6+
"react-app",
7+
"react-app/jest",
218
"prettier/@typescript-eslint",
229
"plugin:prettier/recommended"
2310
],
24-
"globals": {
25-
"document": true,
26-
"window": true
27-
},
28-
"parserOptions": {
29-
"ecmaVersion": 2018,
30-
"sourceType": "module",
31-
"ecmaFeatures": {
32-
"jsx": true
33-
}
34-
},
3511
"rules": {
36-
"arrow-body-style": "warn",
37-
"no-plusplus": ["warn", {
38-
"allowForLoopAfterthoughts": true
39-
}],
40-
"@typescript-eslint/explicit-function-return-type": "off",
41-
"@typescript-eslint/explicit-module-boundary-types": "off",
42-
"@typescript-eslint/no-unused-vars": "error",
43-
"react-hooks/exhaustive-deps": "warn",
44-
"react-hooks/rules-of-hooks": "error",
45-
"import/no-unresolved": "off",
46-
"import/prefer-default-export": "off",
47-
"react/jsx-filename-extension": [
48-
"off", // TODO: Why using js instead of jsx???
49-
{
50-
"extensions": [".jsx", ".tsx"]
51-
}
52-
],
53-
"no-console": "error"
54-
},
55-
"settings": {
56-
"react": {
57-
"version": "detect"
58-
}
12+
"react/jsx-filename-extension": ["warn", { "extensions": [".tsx"] }]
5913
}
6014
}

.github/workflows/ci.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
4-
name: CI/CD
1+
name: CI
52

63
on:
74
push:
@@ -10,17 +7,20 @@ on:
107
branches: [ master ]
118

129
jobs:
13-
deployment:
14-
name: Run test coverage, upload to Codecov and deploy to GitHub Pages
15-
runs-on: ubuntu-latest
10+
deploy:
11+
name: Release and deploy to GitHub Pages
12+
runs-on: ${{ matrix.os }}
1613
strategy:
1714
matrix:
18-
node-version: [12.x]
15+
node-version: [10.x, 12.x]
16+
os: [macos-latest, windows-latest, ubuntu-latest]
1917
steps:
2018
- name: Check repository
2119
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
2222

23-
- name: Use Node.js ${{ matrix.node-version }}
23+
- name: Setup NodeJS ${{ matrix.node-version }}
2424
uses: actions/setup-node@v1
2525
with:
2626
node-version: ${{ matrix.node-version }}
@@ -33,7 +33,7 @@ jobs:
3333
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
3434

3535
- name: Install dependencies
36-
run: yarn
36+
run: yarn install --no-progress --non-interactive
3737

3838
- name: Run test coverage
3939
run: yarn test --coverage
@@ -43,16 +43,15 @@ jobs:
4343
with:
4444
token: ${{ secrets.CODECOV_TOKEN }}
4545

46-
- name: Deploy to GitHub Pages
46+
- name: Release & deploy to GitHub Pages
4747
run: |
48-
git config --global user.name $user_name
49-
git config --global user.email $user_email
50-
git remote set-url origin https://${github_token}@github.com/${repository}
48+
git config --global user.name $USER_NAME
49+
git config --global user.email $USER_EMAIL
50+
git remote set-url origin https://${GITHUB_TOKEN}@github.com/${REPOSITORY}
51+
yarn release
5152
yarn deploy -m "${{ github.event.head_commit.message }}"
5253
env:
53-
user_name: 'github-actions[bot]'
54-
user_email: 'github-actions[bot]@users.noreply.github.com'
55-
github_token: ${{ secrets.DEPLOY_ACCESS_TOKEN }}
56-
repository: ${{ github.repository }}
57-
58-
# Reference: https://github.community/t/run-next-job-sequentially-even-if-a-previous-job-fails/17404/2
54+
USER_NAME: 'github-actions[bot]'
55+
USER_EMAIL: 'github-actions[bot]@users.noreply.github.com'
56+
GITHUB_TOKEN: ${{ github.token }}
57+
REPOSITORY: ${{ github.repository }}

.prettierrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
2+
"arrowParens": "always",
3+
"endOfLine": "lf",
24
"jsxBracketSameLine": false,
35
"printWidth": 80,
6+
"semi": true,
47
"singleQuote": true,
5-
"trailingComma": "all",
6-
"tabWidth": 2
8+
"tabWidth": 2,
9+
"trailingComma": "all"
710
}

.release-it.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"git": {
3+
"commitMessage": "chore(release): release ${version}"
4+
},
5+
"github": {
6+
"release": true
7+
},
8+
"npm": {
9+
"publish": false
10+
},
11+
"plugins": {
12+
"@release-it/conventional-changelog": {
13+
"preset": "angular",
14+
"infile": "CHANGELOG.md"
15+
}
16+
}
17+
}

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
"editor.codeActionsOnSave": {
1111
"source.fixAll.eslint": true
1212
},
13+
"typescript.tsdk": "node_modules/typescript/lib",
1314
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
3+
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
4+
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
5+
// same ids are connected.
6+
// Example:
7+
// "Print to console": {
8+
// "prefix": "log",
9+
// "body": [
10+
// "console.log('$1');",
11+
// "$2"
12+
// ],
13+
// "description": "Log output to console"
14+
// }
15+
"Create React Functional Component": {
16+
"prefix": "crfc",
17+
"body": [
18+
"import React, { memo } from 'react';",
19+
"",
20+
"export const ${1:ComponentName}Component: React.FC = () => <div>Empty</div>;",
21+
"",
22+
"const $1 = memo(${1:ComponentName}Component);",
23+
"$1.displayName = '$1';",
24+
"",
25+
"export default $1;",
26+
""
27+
],
28+
"description": "Create React Functional Component"
29+
}
30+
}

README.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# create-react-app-typescript-template
22

3-
![CI/CD](https://github.com/phatnguyenuit/create-react-app-typescript-template/workflows/CI/CD/badge.svg)
3+
![CI/CD](https://github.com/phatnguyenuit/create-react-app-typescript-template/workflows/CI/badge.svg)
44
[![codecov](https://codecov.io/gh/phatnguyenuit/create-react-app-typescript-template/branch/master/graph/badge.svg?token=4C32ACLQWS)](https://codecov.io/gh/phatnguyenuit/create-react-app-typescript-template)
55
![License](https://img.shields.io/github/license/phatnguyenuit/create-react-app-typescript-template)
66

@@ -9,12 +9,16 @@ Create React App TypeScript template
99

1010
## Features
1111

12-
- Automate workflow to deploy with GitHub Actions
13-
- Code coverage with [Codecov](https://codecov.io)
14-
- Strong static typings with TypeScript
15-
- ESLint
16-
- Prettier
17-
- pre-commit hook with Husky
12+
- Inherit from package [`cra-template-typescript`](https://www.npmjs.com/package/cra-template-typescript)
13+
- Configure `eslint` with `prettier`
14+
- Configure [`husky`](https://typicode.github.io/husky/#/)
15+
- Configure [`lint-staged`](https://github.com/okonet/lint-staged#readme)
16+
- Configure [`prettier`](https://prettier.io/)
17+
- Configure [`commitlint`](https://commitlint.js.org/)
18+
- Configure [`release-it`](https://github.com/release-it/release-it)
19+
- Add default `jest` test coverage options
20+
- Configure sample GitHub actions including test, release and deploy
21+
- Provide sample vscode snippets
1822

1923
# Configure
2024

@@ -32,23 +36,23 @@ In the project directory, you can run:
3236

3337
### `yarn start`
3438

35-
Runs the app in the development mode.<br />
39+
Runs the app in the development mode.\
3640
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
3741

38-
The page will reload if you make edits.<br />
42+
The page will reload if you make edits.\
3943
You will also see any lint errors in the console.
4044

4145
### `yarn test`
4246

43-
Launches the test runner in the interactive watch mode.<br />
47+
Launches the test runner in the interactive watch mode.\
4448
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
4549

4650
### `yarn build`
4751

48-
Builds the app for production to the `build` folder.<br />
52+
Builds the app for production to the `build` folder.\
4953
It correctly bundles React in production mode and optimizes the build for the best performance.
5054

51-
The build is minified and the filenames include the hashes.<br />
55+
The build is minified and the filenames include the hashes.\
5256
Your app is ready to be deployed!
5357

5458
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
@@ -63,12 +67,20 @@ Instead, it will copy all the configuration files and the transitive dependencie
6367

6468
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
6569

66-
## Learn More
70+
### `yarn commit`
71+
72+
Commit with conventional commit powered by `@commitlint/cli` CLI
6773

68-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
74+
### `yarn release`
6975

70-
To learn React, check out the [React documentation](https://reactjs.org/).
76+
Release version for your project powered by `release-it` CLI
7177

72-
## Setup CI/CD
78+
## Learn More
7379

74-
Refer this article: [Setting up a CI/CD workflow on GitHub Actions for a React App (with GitHub Pages and Codecov)](https://dev.to/dyarleniber/setting-up-a-ci-cd-workflow-on-github-actions-for-a-react-app-with-github-pages-and-codecov-4hnp)
80+
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
81+
- Learn React, check out the [React documentation](https://reactjs.org/).
82+
- Learn [GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions)
83+
- Learn [ESLint](https://eslint.org/docs/user-guide/getting-started)
84+
- Learn [Commitlint](https://commitlint.js.org/#/)
85+
- Learn [Release-it](https://github.com/release-it/release-it)
86+
- [Setting up a CI/CD workflow on GitHub Actions for a React App (with GitHub Pages and Codecov)](https://dev.to/dyarleniber/setting-up-a-ci-cd-workflow-on-github-actions-for-a-react-app-with-github-pages-and-codecov-4hnp)

commitlint.config.js

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

0 commit comments

Comments
 (0)