Skip to content

Commit

Permalink
feat: initial boilerplate setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpraful committed Feb 6, 2024
0 parents commit 9ae0784
Show file tree
Hide file tree
Showing 29 changed files with 5,974 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
43 changes: 43 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
],
ignorePatterns: [
'dist',
'.eslintrc.cjs',
'postcss.config.js',
'tailwind.config.js',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2020,
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.browser.json'],
tsconfigRootDir: __dirname,
},
overrides: [
{
files: ['**/*.cjs'],
env: {
node: true,
},
},
],
plugins: ['@tanstack/query', 'react-refresh', 'simple-import-sort'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'simple-import-sort/exports': 2,
'simple-import-sort/imports': 2,
},
}
36 changes: 36 additions & 0 deletions .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pre-merge checks
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install -g yarn && yarn

- name: Install Playwright Browsers
run: yarn playwright install --with-deps

- name: Run Lint
run: yarn lint

- name: Run Unit Tests
run: yarn test:unit

- name: Run E2E Tests
run: yarn test:e2e

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

node_modules
.DS_Store
dist
dist-ssr
*.local

.env.local
.env

yarn-error.log
2 changes: 2 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
2 changes: 2 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @jasonpraful/vite-boilerplate

## 0.0.1

### Patch Changes

- Initial Commit
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright 2024 Jason Praful

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.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Vite Boilerplate

All in one front-end Vite.js + React boilerplate

## Features

- Vite.js
- React
- TypeScript
- Tailwind CSS
- Vitest + React Testing Library
- Playwright

Boilerplate also consists of eslint, prettier, typescript, and tailwindcss
configurations.

## License

MIT
6 changes: 6 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [0, 'always'],
},
}
7 changes: 7 additions & 0 deletions e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from '@playwright/test'

test('has Hello World', async ({ page }) => {
await page.goto('http://localhost:4173')
const text = await page.textContent('h1')
expect(text).toBe('Hello, world!👋')
})
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite Boilerplate</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
81 changes: 81 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "@jasonpraful/vite-boilerplate",
"version": "0.0.1",
"type": "module",
"private": true,
"author": "Jason Praful <jason.praful@gmail.com>",
"license": "MIT",
"description": "A Vite boilerplate with React, TypeScript, Tailwind CSS, and Playwright",
"repository": {
"type": "git",
"url": "https://github.com/jasonpraful/vite-boilerplate"
},
"keywords": [
"vite",
"react",
"typescript",
"tailwindcss",
"playwright"
],
"scripts": {
"dev": "vite",
"build": "vite build",
"format": "prettier --write .",
"lint": "eslint . --ext ts,tsx",
"lint:fix": "eslint . --ext ts,tsx --fix",
"preview": "vite preview",
"test:unit": "vitest",
"test:unit:coverage": "vitest run --coverage",
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:e2e:debug": "playwright test --debug",
"test:e2e:codegen": "playwright codegen",
"playwright:setup": "playwright install --with-deps",
"commitlint": "commitlint --edit",
"version": "changeset version"
},
"dependencies": {
"@tanstack/react-query": "^5.18.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@playwright/test": "^1.41.2",
"@tanstack/eslint-plugin-query": "^5.18.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@testing-library/user-event": "^14.5.2",
"@tsconfig/node18": "18.2.2",
"@tsconfig/vite-react": "^3.0.0",
"@types/node": "18.13.0",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-istanbul": "^1.2.2",
"@vitest/ui": "^1.2.2",
"autoprefixer": "^10.4.17",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.55.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^9.0.10",
"jsdom": "^24.0.0",
"postcss": "^8.4.34",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.0.8",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.2.2"
},
"engines": {
"node": ">=18.0.0"
}
}
67 changes: 67 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { defineConfig, devices } from '@playwright/test'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: 'http://127.0.0.1:4173',
trace: 'on-first-retry',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'yarn build && yarn preview',
url: 'http://localhost:4173',
reuseExistingServer: !process.env.CI,
},
})
6 changes: 6 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
16 changes: 16 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @type {import("prettier").Config} */
module.exports = {
jsxSingleQuote: false,
proseWrap: 'always',
quoteProps: 'as-needed',
requirePragma: false,
semi: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: true,
endOfLine: 'lf',
printWidth: 80,
tailwindConfig: './tailwind.config.ts',
plugins: ['prettier-plugin-tailwindcss'],
}
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { render } from '@testing-library/react'
import { describe, expect, it } from 'vitest'

import App from './App'

describe('App', () => {
it('renders hello world', () => {
const { getByText } = render(<App />)
expect(getByText('Hello, world!👋')).toBeInTheDocument()
})
})
15 changes: 15 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function App() {
return (
<div className="h-dvh bg-slate-400 antialiased">
<div className="relative flex h-screen items-center justify-center ">
<div className="relative flex animate-bounce">
<div className="rounded-md border border-black bg-slate-900 px-10 py-2 text-white">
<h1 className="text-4xl font-bold">Hello, world!👋</h1>
</div>
</div>
</div>
</div>
)
}

export default App
Loading

0 comments on commit 9ae0784

Please sign in to comment.