chore: initial bootstrapping

This commit is contained in:
wanhose 2024-02-29 00:23:54 +01:00
commit 8e9eeecb21
24 changed files with 5733 additions and 0 deletions

24
.commitlintrc Normal file
View File

@ -0,0 +1,24 @@
{
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"scope-case": [
0
],
"header-max-length": [
0,
"always",
110
],
"scope-enum": [
2,
"always",
[
"assets",
"containers",
"tests"
]
]
}
}

40
.eslintrc Normal file
View File

@ -0,0 +1,40 @@
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest-dom/recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"plugin:react/jsx-runtime",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:testing-library/dom"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["import", "simple-import-sort"],
"rules": {
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"react/react-in-jsx-scope": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
},
"settings": {
"react": {
"version": "detect"
}
}
}

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.DS_*
*.log
*.sublime*
**/*.back.*
**/*.backup.*
bower_components
dist
logs
node_modules

1
.husky/commit-msg Executable file
View File

@ -0,0 +1 @@
npx --no -- commitlint --edit "$1"

1
.husky/pre-commit Executable file
View File

@ -0,0 +1 @@
pnpm lint-staged

1
.husky/pre-push Executable file
View File

@ -0,0 +1 @@
pnpm test

6
.lintstagedrc Normal file
View File

@ -0,0 +1,6 @@
{
"src/**/*.ts{,x}": [
"prettier --write",
"eslint --fix"
]
}

2
.prettierignore Normal file
View File

@ -0,0 +1,2 @@
.yarn
build

8
.prettierrc Normal file
View File

@ -0,0 +1,8 @@
{
"bracketSameLine": true,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}

6
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"files.associations": {
".commitlintrc": "json",
".lintstagedrc": "json"
}
}

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 wanhose
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

18
README.md Normal file
View File

@ -0,0 +1,18 @@
# react-typescript-template
A shorter way to start your React project using the latest versions of...
✋ ESLint<br/>
🐶 Husky<br/>
⚛️ React<br/>
💪 TypeScript<br/>
🪶 Vite<br/>
🧪 Vitest with React Testing Library
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
[MIT](https://choosealicense.com/licenses/mit/)

14
index.html Normal file
View File

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>App</title>
<link rel="stylesheet" href="/src/styles/reset.css" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

52
package.json Normal file
View File

@ -0,0 +1,52 @@
{
"type": "module",
"name": "react-typescript-template",
"version": "1.0.0",
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"lint": "tsc && eslint ./src/**/*.{ts,tsx} --fix",
"preinstall": "npx only-allow pnpm",
"prepare": "husky",
"serve": "vite preview",
"test": "vitest --watch=false"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^20.16.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"@vitejs/plugin-react": "^4.3.2",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-testing-library": "^6.3.0",
"husky": "^9.1.6",
"jsdom": "^25.0.1",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"typescript": "^5.6.2",
"vite": "^5.4.8",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.1.2"
},
"engines": {
"node": ">=20.0.0 <21.0.0"
}
}

5402
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

15
src/assets/favicon.svg Normal file
View File

@ -0,0 +1,15 @@
<svg width="410" height="404" viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z" fill="url(#paint0_linear)"/>
<path d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z" fill="url(#paint1_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
<stop stop-color="#41D1FF"/>
<stop offset="1" stop-color="#BD34FE"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFEA83"/>
<stop offset="0.0833333" stop-color="#FFDD35"/>
<stop offset="1" stop-color="#FFA800"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,5 @@
import type { JSX } from 'react';
export function App(): JSX.Element {
return <div>App</div>;
}

View File

@ -0,0 +1,13 @@
import { render, screen } from '@testing-library/react';
import { App } from '../App';
beforeEach(() => {
render(<App />);
});
describe('App', () => {
it('must contain word', () => {
expect(screen.getByText('App')).toBeInTheDocument();
});
});

7
src/main.tsx Normal file
View File

@ -0,0 +1,7 @@
import { App } from 'containers/App';
import ReactDOM from 'react-dom/client';
const node = document.getElementById('root') as HTMLElement;
const root = ReactDOM.createRoot(node);
root.render(<App />);

45
src/styles/reset.css Normal file
View File

@ -0,0 +1,45 @@
*,
*::after,
*::before {
box-sizing: border-box;
}
* {
margin: 0;
}
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
canvas,
img,
picture,
svg,
video {
display: block;
max-width: 100%;
}
button,
input,
select,
textarea {
font: inherit;
}
h1,
h2,
h3,
h4,
h5,
h6,
p {
overflow-wrap: break-word;
}
#__next,
#root {
isolation: isolate;
}

6
src/tests/setup.ts Normal file
View File

@ -0,0 +1,6 @@
import '@testing-library/jest-dom/vitest';
import { cleanup } from '@testing-library/react';
import { afterEach } from 'vitest';
afterEach(cleanup);

1
src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

22
tsconfig.json Normal file
View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"baseUrl": "./src",
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react-jsx",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"moduleResolution": "Node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ESNext",
"types": ["vitest/globals"],
"useDefineForClassFields": true
},
"include": ["./src"]
}

14
vite.config.ts Normal file
View File

@ -0,0 +1,14 @@
/// <reference types="vitest" />
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [react(), tsconfigPaths()],
test: {
environment: 'jsdom',
globals: true,
setupFiles: './src/tests/setup.ts',
},
});