├── .github
└── workflows
│ └── publish.yaml
├── LICENSE
├── README.md
├── package.json
├── template.json
└── template
├── .editorconfig
├── .github
└── workflows
│ ├── lint.yml
│ └── test.yml
├── .stylelintrc.json
├── LICENSE
├── Makefile
├── README.md
├── cypress.config.ts
├── gitignore
├── jest.config.js
├── public
└── index.html
├── src
├── App.tsx
├── assets
│ └── styles
│ │ └── sakura.scss
├── index.tsx
├── react-app-env.d.ts
└── sections
│ └── users
│ ├── UserCard.module.scss
│ ├── UserCard.tsx
│ └── useUsers.ts
├── tests
├── App.spec.tsx
├── e2e
│ ├── support
│ │ ├── commands.ts
│ │ └── e2e.ts
│ ├── tests
│ │ └── home.spec.ts
│ └── tsconfig.json
└── setupTests.ts
└── tsconfig.json
/.github/workflows/publish.yaml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | branches:
4 | - 'main'
5 |
6 | jobs:
7 | publish:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v3
11 | - uses: actions/setup-node@v3
12 | with:
13 | node-version: 12
14 | - run: npm install
15 | - uses: JS-DevTools/npm-publish@v1
16 | with:
17 | token: ${{ secrets.NPM_TOKEN }}
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Codely Enseña y Entretiene SL
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
18 | Template for creating your React apps with TypeScript following best practices: Unit and end-to-end tests, Continuous Integration, and linting.
19 |
20 |
21 | Stars are welcome 😊
22 |
23 |
24 | ## 🚀 Using this CRA template
25 |
26 | ### 🤔 CRA introduction
27 |
28 | React officially support to create your custom templates for the Create React App (CRA) utility.
29 |
30 | This Codely template is just a way to optimize even more the default CRA template adding the bare minimum [features we consider necessary on every React project](https://github.com/CodelyTV/cra-template-codely#-template-features).
31 |
32 | ### ⚡ How to create your React app
33 |
34 | Create your React app with TypeScript and taking advantage of the scaffolding provided by this template executing this `npx` command in your terminal:
35 |
36 | ```bash
37 | npx create-react-app my-app --template @codelytv/cra-template-codely
38 | ```
39 |
40 | Or, if you prefer to use Yarn instead of npm:
41 |
42 | ```bash
43 | yarn create react-app --template @codelytv/cra-template-codely my-app
44 | ```
45 |
46 | It will create a `my-app` folder inside the directory where you execute the command. You will find a `README.md` in the root of your generated project with the instructions on how to build, test, and run your application 🤟
47 |
48 | ### 🌩️ What does CRA do while creating the project
49 |
50 | The `my-app` created with the `npx` command will contain a ready-to-use application thanks to the magic CRA does behind the scenes:
51 |
52 | - Copy everything inside [this CRA `template` folder](template) into your project root directory
53 | - Create the project `package.json` based on the dependencies that CRA needs such as React itself _in the latest version possible_, plus the dependencies added by Codely in the [`template.json`](template.json)
54 | - Create the project `.gitignore` file based on the [`template/gitignore`](template/gitignore)
55 | - Depending on if you have used Yarn or npm while creating the project, it will have available the corresponding commands and config files in order to run the generated app
56 | - Install all the dependencies
57 |
58 | ## 🌈 Template Features
59 |
60 | - [TypeScript](https://www.typescriptlang.org)
61 | - [ESLint](https://eslint.org) and [Prettier](https://prettier.io) already configured with the [🤏 Codely's configuration](https://github.com/CodelyTV/eslint-config-codely)
62 | - [Jest](https://jestjs.io) with [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) for the unit tests
63 | - [Cypress](https://www.cypress.io) with [Testing Library](https://testing-library.com/docs/cypress-testing-library) for the end-to-end tests
64 | - [GitHub Action Workflows](https://github.com/features/actions) set up to run tests and linting on push
65 | - [Makefile](https://github.com/CodelyTV/cra-template-codely/blob/main/template/Makefile) for standardize how to run projects
66 | - [Sass](https://sass-lang.com) to supercharge CSS with nested classes and more fun
67 | - [.editorconfig](https://editorconfig.org) for sharing the IDE config
68 |
69 |
70 | ## 💻 Improving this CRA template
71 |
72 | You can improve this CRA and make Pull Requests to this repository. In order to locally test how your improvements generate a new project, you can specify a local template file with the following command:
73 |
74 | ```bash
75 | npx create-react-app my-app --template file:../path/to/cra-template-codely
76 | ```
77 |
78 | ## 👌 Codely Code Quality Standards
79 |
80 | Publishing this package we are committing ourselves to the following code quality standards:
81 |
82 | - 🤝 Respect **Semantic Versioning**: No breaking changes in patch or minor versions
83 | - 🤏 No surprises in transitive dependencies: Use the **bare minimum dependencies** needed to meet the purpose
84 | - 🎯 **One specific purpose** to meet without having to carry a bunch of unnecessary other utilities
85 | - ✅ **Tests** as documentation and usage examples
86 | - 📖 **Well documented ReadMe** showing how to install and use
87 | - ⚖️ **License favoring Open Source** and collaboration
88 |
89 | ## 🔀 Related templates
90 |
91 | Opinionated TypeScript skeletons ready for different purposes:
92 |
93 | - [🔷🌱 TypeScript Basic Skeleton](https://github.com/CodelyTV/typescript-basic-skeleton)
94 | - [🔷🕸️ TypeScript Web Skeleton](https://github.com/CodelyTV/typescript-web-skeleton)
95 | - [🔷🌍 TypeScript API Skeleton](https://github.com/CodelyTV/typescript-api-skeleton)
96 | - [🔷✨ TypeScript DDD Skeleton](https://github.com/CodelyTV/typescript-ddd-skeleton)
97 |
98 | This same skeleton philosophy implemented in other programming languages:
99 |
100 | - [✨ JavaScript Basic Skeleton](https://github.com/CodelyTV/javascript-basic-skeleton)
101 | - [☕ Java Basic Skeleton](https://github.com/CodelyTV/java-basic-skeleton)
102 | - [📍 Kotlin Basic Skeleton](https://github.com/CodelyTV/kotlin-basic-skeleton)
103 | - [🧬 Scala Basic Skeleton](https://github.com/CodelyTV/scala-basic-skeleton)
104 | - [🦈 C# Basic Skeleton](https://github.com/CodelyTV/csharp-basic-skeleton)
105 | - [🐘 PHP Basic Skeleton](https://github.com/CodelyTV/php-basic-skeleton)
106 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@codelytv/cra-template-codely",
3 | "version": "1.0.3",
4 | "keywords": [
5 | "react",
6 | "create-react-app",
7 | "template",
8 | "typescript"
9 | ],
10 | "description": "Template for creating your React apps with TypeScript following best practices: Unit and end-to-end tests, Continuous Integration, and linting.",
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/CodelyTV/cra-template-codely"
14 | },
15 | "author": "codelytv",
16 | "license": "MIT",
17 | "files": [
18 | "template",
19 | "template.json"
20 | ],
21 | "engines": {
22 | "node": ">=14"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "package": {
3 | "scripts": {
4 | "cy:open": "cypress open",
5 | "cy:run": "cypress run",
6 | "test": "jest --watch --config=jest.config.js",
7 | "lint": "eslint --ignore-path .gitignore . && stylelint **/*.scss",
8 | "lint:fix": "eslint --fix --ignore-path .gitignore . && stylelint --fix **/*.scss"
9 | },
10 | "devDependencies": {
11 | "@swc/core": "^1.3.6",
12 | "@swc/jest": "^0.2.23",
13 | "@testing-library/jest-dom": "^5.14.1",
14 | "@testing-library/react": "^13.0.0",
15 | "@testing-library/user-event": "^13.2.1",
16 | "@types/jest": "^27.0.1",
17 | "@types/node": "^16.7.13",
18 | "@types/react": "^18.0.0",
19 | "@types/react-dom": "^18.0.0",
20 | "typescript": "^4.4.2",
21 | "eslint-config-codely": "^2.1.1",
22 | "identity-obj-proxy": "^3.0.0",
23 | "jest-transform-stub": "^2.0.0",
24 | "cypress": "10.3.0",
25 | "@testing-library/cypress": "^8.0.2",
26 | "stylelint": "^14.1.0",
27 | "stylelint-config-rational-order": "^0.1.2",
28 | "stylelint-config-standard-scss": "^3.0.0",
29 | "stylelint-order": "^5.0.0",
30 | "sass": "^1.55.0"
31 | },
32 | "dependencies": {},
33 | "eslintConfig": {
34 | "extends": [
35 | "react-app",
36 | "react-app/jest",
37 | "eslint-config-codely/typescript"
38 | ],
39 | "parserOptions": {
40 | "project": ["./tsconfig.json"]
41 | },
42 | "settings": {
43 | "import/resolver": {
44 | "node": {
45 | "extensions": [".js", ".jsx", ".ts", ".tsx"]
46 | }
47 | }
48 | },
49 | "overrides": [
50 | {
51 | "files": ["**/tests/e2e/**/*.spec.ts"],
52 | "rules": {
53 | "testing-library/await-async-query": 0,
54 | "@typescript-eslint/no-unsafe-member-access": 0,
55 | "@typescript-eslint/no-unsafe-call": 0,
56 | "testing-library/prefer-screen-queries": 0
57 | }
58 | }
59 | ]
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/template/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 | max_line_length = 100
7 | indent_style = tab
8 |
--------------------------------------------------------------------------------
/template/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: lint
2 |
3 | on: push
4 |
5 | jobs:
6 | lint:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v3
11 |
12 | - uses: actions/setup-node@v3
13 | with:
14 | node-version: 16
15 | cache: 'npm'
16 |
17 | - name: Install Dependencies
18 | run: npm install
19 |
20 | - name: Lint
21 | run: npm run lint
22 |
--------------------------------------------------------------------------------
/template/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: test
2 |
3 | on: push
4 |
5 | jobs:
6 | unit:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v3
11 |
12 | - uses: actions/setup-node@v3
13 | with:
14 | node-version: 16
15 | cache: 'npm'
16 |
17 | - name: Install Dependencies
18 | run: npm install
19 |
20 | - name: Test
21 | run: npx jest --config=jest.config.js
22 | e2e:
23 | runs-on: ubuntu-latest
24 |
25 | steps:
26 | - uses: actions/checkout@v3
27 |
28 | - uses: actions/setup-node@v3
29 | with:
30 | node-version: 16
31 | cache: 'npm'
32 |
33 | - name: Install Dependencies
34 | run: npm install
35 |
36 | - name: Cypress run
37 | uses: cypress-io/github-action@v4
38 | with:
39 | build: npm run build
40 | start: npm run start
41 | wait-on: "http://localhost:3000"
42 |
--------------------------------------------------------------------------------
/template/.stylelintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "overrides": [
3 | {
4 | "files": ["**/*.scss"],
5 | "customSyntax": "postcss-scss"
6 | }
7 | ],
8 | "extends": ["stylelint-config-standard-scss", "stylelint-config-rational-order"],
9 | "rules": {
10 | "scss/dollar-variable-pattern": null,
11 | "scss/dollar-variable-empty-line-before": null,
12 | "selector-id-pattern": null,
13 | "selector-class-pattern": null
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/template/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) ${Year} ${Company}
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/template/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: build
2 | build: deps compile
3 |
4 | .PHONY: deps
5 | deps:
6 | npm install
7 |
8 | .PHONY: compile
9 | compile:
10 | npm run build
11 |
12 | .PHONY: start
13 | start:
14 | npm start
15 |
16 | .PHONY: test
17 | test:
18 | npm test
19 |
20 | .PHONY: lint
21 | lint:
22 | npm run lint
23 |
24 | .PHONY: lint-fix
25 | lint-fix:
26 | npm run lint:fix
--------------------------------------------------------------------------------
/template/README.md:
--------------------------------------------------------------------------------
1 |