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 config & github action CI #101

Merged
merged 6 commits into from
Jun 23, 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
12 changes: 11 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
[*]indent_size = 2
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = unset
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
18 changes: 9 additions & 9 deletions .env.demo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
VITE_DEVELOPEMENT_GOOGLE_OAUTH_URL = 'http://localhost:4000/oauth/google'
VITE_PRODUCTION_GOOGLE_OAUTH_URL = 'http://rendebe/oauth/google'
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'
VITE_DEVELOPEMENT_GOOGLE_OAUTH_URL = 'http://localhost:4000/oauth/google'
VITE_PRODUCTION_GOOGLE_OAUTH_URL = 'http://rendebe/oauth/google'


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'
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
node_modules
dist
public
191 changes: 136 additions & 55 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,136 @@
{
"env": {
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:jsx-a11y/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": ["react", "prettier"],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
}
},
"react": {
"version": "detect"
}
},
"rules": {
"react/jsx-no-target-blank": "error",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"eqeqeq": "error",
"no-nested-ternary": "error",
"require-await": "error",
"no-console": "error",
"prettier/prettier": [
"error",
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"plugins": ["prettier-plugin-tailwindcss"],
"arrowParens": "always",
"semi": true,
"trailingComma": "all",
"tabWidth": 2,
"endOfLine": "auto",
"useTabs": false,
"singleQuote": false,
"printWidth": 80
}
],
"@typescript-eslint/no-unused-vars": "warn"
}
}
{
"env": { "node": true, "browser": true },
"$schema": "https://json.schemastore.org/eslintrc",
// "root": true,
"plugins": [
"react",
"prettier",
"@typescript-eslint",
// "@stylistic",
"import",
"promise",
"jsx-a11y",
"react-refresh"
],
"ignorePatterns": [
"node_modules/",
"dist/",
"server.js",
"*.d.ts",
"*.config.ts"
],
"extends": [
// extends mean use config from devDependencies that community created or recommended

// default eslint
"eslint:recommended", //@eslint/js (@eslint/js and eslint package in package.json is the same thing)

// PLUGIN

// javascript
"plugin:promise/recommended", //eslint-plugin-promise
"plugin:import/recommended", //eslint-plugin-import

// typescript eslint
"plugin:@typescript-eslint/recommended", //@typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/stylistic", //@typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/recommended-type-checked", //@typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/stylistic-type-checked", //@typescript-eslint/eslint-plugin
"plugin:import/typescript", //eslint-plugin-import and eslint-import-resolver-typescript

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

// react
"plugin:jsx-a11y/recommended", //eslint-plugin-jsx-a11y
"plugin:react/recommended", //eslint-plugin-react
"plugin:react/jsx-runtime", //eslint-plugin-react
"plugin:react-hooks/recommended", //eslint-plugin-react-hooks

// 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
"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
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": "latest",
"project": "./tsconfig.json",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
// rule that override the extends config above
// normal code
"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 }
// }
// ],

// plugin
"import/no-unresolved": "error", //eslint-plugin-import and eslint-import-resolver-typescript

// typescript
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-unused-vars": "warn",

// react
"react-refresh/only-export-components": "warn", //eslint-plugin-react-refresh
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn", //check useEffect
"react/jsx-no-target-blank": "warn",
"react/self-closing-comp": [
"error",
{
"component": true,
"html": true
}
],

// override prettier
"prettier/prettier": [
"error",
{},
{
"usePrettierrc": true
}
]
},
"settings": {
// need to set react version for eslint-plugin-react, doesn't auto detect by default
"react": {
"version": "detect"
},
"import/resolver": {
//eslint-plugin-import and eslint-import-resolver-typescript
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
}
}
}
}
71 changes: 71 additions & 0 deletions .github/workflows/checkPR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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

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

# - name: Install Node.js
# 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

- uses: actions/cache@v4
name: Setup pnpm node_module cache
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: prettier:check && pnpm run eslint:check-allow-warning && pnpm run check-types
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
.env
deploy
.firebase
.DS_Store
.DS_Store
.idea
5 changes: 3 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
npm run lint-staged
npm run build
echo "Running pre-commit hook"
pnpm run lint-staged
pnpm run lint
6 changes: 6 additions & 0 deletions .postcssrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": {
"tailwindcss": {},
"autoprefixer": {}
}
}
10 changes: 8 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
node_modules/
dist/
# Prettier will also follow rules specified in the ".gitignore" by default.
# Ignore build and coverage directories:
coverage
build
dist
node_modules
.husky
public
25 changes: 13 additions & 12 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"plugins": ["prettier-plugin-tailwindcss"],
"$schema": "https://json.schemastore.org/prettierrc.json",
"arrowParens": "always",
"semi": true,
"trailingComma": "all",
"tabWidth": 2,
"endOfLine": "auto",
"useTabs": false,
"singleQuote": false,
"printWidth": 80
}
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"plugins": ["prettier-plugin-tailwindcss"],
"printWidth": 80,
"tabWidth": 2,
"trailingComma": "all",
"arrowParens": "always",
"endOfLine": "auto",
"useTabs": false,
"semi": true,
"singleQuote": false,
"jsxSingleQuote": false
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
{
"typescript.tsdk": "node_modules/typescript/lib"
}
28 changes: 12 additions & 16 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"hosting": {
"public": "deploy",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
{
"hosting": {
"public": "deploy",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Loading
Loading