Added vite-react-ts-setup.yml

main
Yiqing Zhu 2023-06-07 21:58:32 +10:00
parent ca727dad65
commit 50b8b47b11
4 changed files with 97 additions and 0 deletions

29
.eslintrc.json 100644
View File

@ -0,0 +1,29 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
],
"plugins": ["react", "@typescript-eslint", "prettier"],
"env": {
"browser": true,
"node": true,
"es2021": true
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"prettier/prettier": "error",
"@typescript-eslint/no-empty-function": "off"
}
}

View File

@ -0,0 +1,47 @@
name: Setup Vite React TS Project
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Install Yarn
run: npm install -g yarn
- name: Create Vite Project
run: npx create-vite . --template react-ts
- name: Install ESlint and Prettier
run: |
yarn add --dev eslint prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react @typescript-eslint/eslint-plugin @typescript-eslint/parser husky lint-staged
- name: Copy ESLint and Prettier Configuration
run: |
cp .eslintrc.json .eslintrc.json
cp .prettierrc .prettierrc
cp lint-staged.config.json lint-staged.config.json
- name: Update package.json scripts
run: |
npx json -I -f package.json -e 'this.scripts.prettier="prettier \\"src/**/*.{js,jsx,ts,tsx,css,scss,md}\\" --write"; this.scripts["format:check"]="yarn prettier -- --check"; this.scripts["format:write"]="yarn prettier -- --write"; this.scripts["types:check"]="tsc --noEmit --pretty"; this.scripts.lint="eslint --ext .js,.jsx,.ts,.tsx src --no-error-on-unmatched-pattern"; this.scripts["lint:fix"]="eslint --ext .js,.jsx,.ts,.tsx src --fix --no-error-on-unmatched-pattern"; this.scripts.fix="yarn format:write && yarn lint:fix";'
- name: Commit and Push
run: |
git config --global user.name "JKlancer"
git config --global user.email "jasonzhuyq@outlook.com"
git add .
git commit -m "Setup project with Vite, React-TS, ESLint, and Prettier"
git push

13
.prettierrc 100644
View File

@ -0,0 +1,13 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}

View File

@ -0,0 +1,8 @@
module.exports = {
'*.json': ['npm run format:check'],
'*.{ts,tsx,js,jsx}': [
'npm run lint',
"bash -c 'npm run types:check'",
'npm run format:check',
],
};