From e60840deb939fc9b1b0d14929ffc5d55b5bae638 Mon Sep 17 00:00:00 2001 From: totto2727 Date: Fri, 16 Feb 2024 00:00:02 +0900 Subject: [PATCH 1/6] chore: add code format rules Added .prettierrc to enable Prettier in various editors and IDEs. - add .prettierrc - use almost default rule --- .prettierrc | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..e69de29bb From 427e632c0fe7856a5556cbdad9b047b0a79c2b26 Mon Sep 17 00:00:00 2001 From: totto2727 Date: Fri, 16 Feb 2024 00:00:14 +0900 Subject: [PATCH 2/6] chore: add .editorconfig Added .editorconfig to reduce differences between users --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..b6c04c5e2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true + +[*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,json,yaml,toml,css,html,md}] +indent_style = space +indent_size = 2 From 00cd977d606f04637d230c13eab7ccce2b4ede25 Mon Sep 17 00:00:00 2001 From: totto2727 Date: Fri, 16 Feb 2024 00:01:51 +0900 Subject: [PATCH 3/6] chore: add npm scripts for check and fix Added fix and check commands to NPM scripts - npm-run-all is used for future extensibility --- package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d34691be..f37578239 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,11 @@ "generate": "drizzle-kit generate:sqlite --schema=./src/db/schema --out=./migrations", "up": "wrangler d1 migrations apply sonicjs --local", "up:prod": "wrangler d1 migrations apply sonicjs", - "tail": "wrangler pages deployment tail" + "tail": "wrangler pages deployment tail", + "check": "run-p check:*", + "check:prettier": "prettier --check --cache . **/*.css !**/*.md", + "fix": "run-s fix:*", + "fix:prettier": "prettier --write --cache . **/*.css !**/*.md" }, "keywords": [], "author": "", @@ -52,3 +56,4 @@ "uuid": "^9.0.0" } } + From 8e3042da65f0cee7242dd0947d47b9bfca450861 Mon Sep 17 00:00:00 2001 From: totto2727 Date: Fri, 16 Feb 2024 00:04:08 +0900 Subject: [PATCH 4/6] chore: add vscode project settings Many developers currently use VSCode or editors based on it. Therefore, adding a standard VSCode setting to this project should help many developers. Developers using other editors will also be able to adjust based on these settings. - add default format settings - add required extensions settings - .vscode/settings.json added to git management --- .gitignore | 2 +- .vscode/extensions.json | 8 ++++++++ .vscode/settings.json | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index b073a0113..e6fffd87e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ dist .wrangler/state .wrangler/tmp wrangler.toml -.vscode/settings.json \ No newline at end of file + diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..f59797378 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "davidanson.vscode-markdownlint", + "editorconfig.editorconfig" + ] +} + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..aaba34402 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" + } +} + From 2d15e498a9c8082a9be1f164339f1446f06d1138 Mon Sep 17 00:00:00 2001 From: totto2727 Date: Fri, 16 Feb 2024 00:17:17 +0900 Subject: [PATCH 5/6] chore: add github actions for format Public repositories allow GitHub Actions for free. This ensures PR quality and improves the developer experience. https://docs.github.com/ja/billing/managing-billing-for-github-actions/about-billing-for-github-actions --- .github/workflows/static-analytics.yaml | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/static-analytics.yaml diff --git a/.github/workflows/static-analytics.yaml b/.github/workflows/static-analytics.yaml new file mode 100644 index 000000000..101d07ec6 --- /dev/null +++ b/.github/workflows/static-analytics.yaml @@ -0,0 +1,28 @@ +name: Static Analytics + +on: + workflow_dispatch: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + static-analytics: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Packages Install + run: npm ci + + - name: Static Check + run: npm run check + From 090648dbd85a5f8888e10c1685e0ed4501ce9ece Mon Sep 17 00:00:00 2001 From: totto2727 Date: Fri, 16 Feb 2024 20:24:34 +0900 Subject: [PATCH 6/6] chore: exclude migrations from formatting --- .prettierignore | 2 ++ package.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..4ae60b77f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +migrations/ +*.md diff --git a/package.json b/package.json index f37578239..99e47a9dc 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,9 @@ "up:prod": "wrangler d1 migrations apply sonicjs", "tail": "wrangler pages deployment tail", "check": "run-p check:*", - "check:prettier": "prettier --check --cache . **/*.css !**/*.md", + "check:prettier": "prettier --check --cache . **/*.css", "fix": "run-s fix:*", - "fix:prettier": "prettier --write --cache . **/*.css !**/*.md" + "fix:prettier": "prettier --write --cache . **/*.css" }, "keywords": [], "author": "",