Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: new eslint and github action CI #5

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
end_of_line = unset
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
14 changes: 8 additions & 6 deletions .env.demo
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# production
PRODUCTION_BACKEND_URL="https://backend.onrender.com"
VITE_PRODUCTION_BACKEND_URL="https://backend.onrender.com"
VITE_DEVELOPEMENT_GOOGLE_OAUTH_URL = 'http://localhost:4000/oauth/google'
VITE_PRODUCTION_GOOGLE_OAUTH_URL = 'http://rendebe/oauth/google'

# development
DEVELOPMENT_BACKEND_URL="http://localhost:3000"
VITE_DEVELOPMENT_BACKEND_URL="http://localhost:3000"

VITE_DEVELOPEMENT_FACEBOOK_OAUTH_URL = 'http://localhost:4000/oauth/facebook'
VITE_PRODUCTION_FACEBOOK_OAUTH_URL = 'http://renderbe/oauth/facebook'

VITE_PRODUCTION_BACKEND_URL = 'http://renderbe.com'
VITE_DEVELOPMENT_BACKEND_URL = 'http://localhost:4000'
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
public
45 changes: 24 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"env": { "node": true, "browser": true },
"$schema": "https://json.schemastore.org/eslintrc",
"root": true,
// "root": true,
"plugins": [
"react",
"prettier",
"@typescript-eslint",
"@stylistic",
// "@stylistic",
"import",
"promise",
"jsx-a11y",
Expand Down Expand Up @@ -39,7 +39,7 @@
"plugin:import/typescript", //eslint-plugin-import and eslint-import-resolver-typescript

// eslint stylistic
"plugin:@stylistic/recommended-extends", //@stylistic/eslint-plugin
// "plugin:@stylistic/recommended-extends", //@stylistic/eslint-plugin

// react
"plugin:jsx-a11y/recommended", //eslint-plugin-jsx-a11y
Expand All @@ -50,7 +50,7 @@
// tailwindcss
"plugin:tailwindcss/recommended", //eslint-plugin-tailwindcss
// prettier THIS MUST BE LAST
// "plugin:prettier/recommended", //eslint-PLUGIN-prettier //disable because focus on new @stylistic/eslint-plugin
"plugin:prettier/recommended", //eslint-PLUGIN-prettier //disable because focus on new @stylistic/eslint-plugin
"prettier" //eslint-CONFIG-prettier (turn off eslint **rules** that conflict with prettier), turn on prettier/prettier rules
//eslint-CONFIG-prettier is used in "check-conflict-prettier-eslint" in package.json
],
Expand All @@ -69,20 +69,21 @@
"no-console": "error",
"require-await": "error",
"eqeqeq": "error",
"no-nested-ternary": "error",

// eslint stylistic
"@stylistic/quotes": ["error", "double"],
"@stylistic/jsx-one-expression-per-line": "off",
"@stylistic/semi": ["error", "always"],
"@stylistic/arrow-parens": ["error", "always"],
"@stylistic/brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"@stylistic/member-delimiter-style": [
"error",
{
"multiline": { "delimiter": "semi", "requireLast": true },
"singleline": { "delimiter": "semi", "requireLast": false }
}
],
// "@stylistic/quotes": ["error", "double"],
// "@stylistic/jsx-one-expression-per-line": "off",
// "@stylistic/semi": ["error", "always"],
// "@stylistic/arrow-parens": ["error", "always"],
// "@stylistic/brace-style": ["error", "1tbs", { "allowSingleLine": true }],
// "@stylistic/member-delimiter-style": [
// "error",
// {
// "multiline": { "delimiter": "semi", "requireLast": true },
// "singleline": { "delimiter": "semi", "requireLast": false }
// }
// ],

// plugin
"import/no-unresolved": "error", //eslint-plugin-import and eslint-import-resolver-typescript
Expand Down Expand Up @@ -121,13 +122,15 @@
"react": {
"version": "detect"
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"] //eslint-plugin-import and eslint-import-resolver-typescript
},
"import/resolver": {
//eslint-plugin-import and eslint-import-resolver-typescript
"typescript": true,
"node": true
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
}
}
}
}
70 changes: 70 additions & 0 deletions .github/workflows/checkPR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Run: Check CI on PR
name: Check CI on PR

on:
pull_request:
branches: ["main"]

jobs:
lint_PR:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check pnpm standalone
uses: actions/cache@v4
with:
path: /home/runner/setup-pnpm/node_modules/.bin/pnpm
key: ${{ runner.os }}-pnpm-standalone
restore-keys: |
${{ runner.os }}-pnpm-standalone

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
standalone: false

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20

# - name: which pnpm
# shell: bash
# run: |
# which pnpm
# env:
# TEST_TEST: ${{ steps.pnpmahihi.outputs.bin_dest }}

# - name: echo echo $PNPM_HOME
# shell: bash
# run: |
# echo $PNPM_HOME

# - name: echo pnpm store directory
# shell: bash
# run: |
# pnpm store path

# - name: Get pnpm store directory
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm node_module cache
uses: actions/cache@v4
with:
path: /home/runner/setup-pnpm/node_modules/.bin/store/v3
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm run prettier:check && pnpm run eslint:check-allow-warning && pnpm run check-types
26 changes: 5 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
node_modules
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.env
deploy
.firebase
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.idea
5 changes: 3 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
yarn run lint-staged
yarn run lint
echo "Running pre-commit hook"
pnpm run lint-staged
pnpm run lint
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ coverage
build
dist
node_modules
husky
.husky
public
Loading