From a61bfd0626f0e885035e451fb7cb7088e3ffac11 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:39:10 +0300 Subject: [PATCH] feat: add formatters (#26) Co-authored-by: Almanov Nikita <131481562+nikkeyl@users.noreply.github.com> --- .ecrc | 5 +++ .github/CODEOWNERS | 1 + .github/dependabot.yaml | 15 +++++++++ .github/workflows/commitlint.yaml | 38 ++++++++++++++++++++++ .github/workflows/create-pull-request.yaml | 21 ++++++++++++ .github/workflows/editorconfig.yaml | 29 +++++++++++++++++ .github/workflows/remark.yaml | 33 +++++++++++++++++++ .gitignore | 5 +++ .husky/commit-msg | 1 + .husky/post-merge | 1 + .husky/pre-commit | 1 + .remarkrc.json | 7 ++++ commitlint.config.ts | 24 ++++++++++++++ lint-staged.config.js | 3 ++ package.json | 21 ++++++++++++ 15 files changed, 205 insertions(+) create mode 100644 .ecrc create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/commitlint.yaml create mode 100644 .github/workflows/create-pull-request.yaml create mode 100644 .github/workflows/editorconfig.yaml create mode 100644 .github/workflows/remark.yaml create mode 100644 .gitignore create mode 100644 .husky/commit-msg create mode 100644 .husky/post-merge create mode 100644 .husky/pre-commit create mode 100644 .remarkrc.json create mode 100644 commitlint.config.ts create mode 100644 lint-staged.config.js create mode 100644 package.json diff --git a/.ecrc b/.ecrc new file mode 100644 index 0000000..918769a --- /dev/null +++ b/.ecrc @@ -0,0 +1,5 @@ +{ + "exclude": [ + "README.md" + ] +} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..74ad750 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @nikkeyl diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..f6ed5e3 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,15 @@ +version: 2 + +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + day: sunday + + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + day: sunday + versioning-strategy: increase diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml new file mode 100644 index 0000000..00907df --- /dev/null +++ b/.github/workflows/commitlint.yaml @@ -0,0 +1,38 @@ +name: Commit Lint + +on: + push: + +jobs: + commit-lint: + name: Commit Lint + + if: ${{ github.actor != 'dependabot[bot]' }} + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set Up BunJS + uses: oven-sh/setup-bun@v2 + + - name: Install Dependencies + run: bun i + + - name: Extract Commit Message (Push) + if: ${{ github.event_name }} == 'push' + run: | + git log -1 --pretty=%B > commit_message.txt + + - name: Extract Commit Message (Pull Request) + if: ${{ github.event_name }} == 'pull_request' + run: | + git show -s --format=%B > commit_message.txt + + - name: Lint + run: | + COMMIT_MESSAGE=$(cat commit_message.txt) + echo "$COMMIT_MESSAGE" | bun commitlint diff --git a/.github/workflows/create-pull-request.yaml b/.github/workflows/create-pull-request.yaml new file mode 100644 index 0000000..658422e --- /dev/null +++ b/.github/workflows/create-pull-request.yaml @@ -0,0 +1,21 @@ +name: Create Pull Request + +on: + push: + +jobs: + create-pull-request: + name: Create Pull Request + + if: ${{ github.actor != 'dependabot[bot]' }} + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Create Pull Request + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PULL_REQUEST_BRANCH: main + PULL_REQUEST_TITLE: ${{ github.event.head_commit.message }} + uses: vsoch/pull-request-action@master diff --git a/.github/workflows/editorconfig.yaml b/.github/workflows/editorconfig.yaml new file mode 100644 index 0000000..6e40d76 --- /dev/null +++ b/.github/workflows/editorconfig.yaml @@ -0,0 +1,29 @@ +name: Editorconfig + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + editorconfig: + name: Editorconfig + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set Up BunJS + uses: oven-sh/setup-bun@v2 + + - name: Install Dependencies + run: bun i + + - name: Lint + run: bun lint:editorconfig diff --git a/.github/workflows/remark.yaml b/.github/workflows/remark.yaml new file mode 100644 index 0000000..22ee412 --- /dev/null +++ b/.github/workflows/remark.yaml @@ -0,0 +1,33 @@ +name: Remark + +on: + pull_request: + branches: + - main + paths: + - '**/*.md' + push: + branches: + - main + paths: + - '**/*.md' + +jobs: + remark: + name: Remark + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set Up BunJS + uses: oven-sh/setup-bun@v2 + + - name: Install Dependencies + run: bun i + + - name: Lint + run: bun lint:md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6dc501f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Bun +bun.lockb + +# Directories +node_modules diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..008c127 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +bun commitlint --edit diff --git a/.husky/post-merge b/.husky/post-merge new file mode 100644 index 0000000..92d4309 --- /dev/null +++ b/.husky/post-merge @@ -0,0 +1 @@ +bun git-pull-run --pattern 'package.json' --command 'bun i' diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..00a9d3c --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +bun lint-staged diff --git a/.remarkrc.json b/.remarkrc.json new file mode 100644 index 0000000..c938caa --- /dev/null +++ b/.remarkrc.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "remark-preset-lint-consistent", + "remark-preset-lint-markdown-style-guide", + "remark-preset-lint-recommended" + ] +} diff --git a/commitlint.config.ts b/commitlint.config.ts new file mode 100644 index 0000000..7e121be --- /dev/null +++ b/commitlint.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from '@archoleat/commitlint-define-config'; + +export default defineConfig({ + extends: ['@commitlint/config-conventional'], + rules: { + 'type-enum': [ + 2, + 'always', + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'spec', + 'style', + ], + ], + }, +}); diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 0000000..f762f37 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,3 @@ +export default { + '**/*.md': 'remark --quiet --frail' +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..6945c64 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "scripts": { + "lint:editorconfig": "editorconfig-checker", + "lint:md": "remark . --quiet --frail" + }, + "devDependencies": { + "@archoleat/commitlint-define-config": "^1.0.9", + "@commitlint/cli": "^19.4.0", + "@commitlint/config-conventional": "^19.2.2", + "@commitlint/types": "^19.0.3", + "editorconfig-checker": "^5.1.8", + "git-pull-run": "^1.4.0", + "husky": "^9.1.4", + "lint-staged": "^15.2.9", + "remark": "15.0.1", + "remark-cli": "^12.0.1", + "remark-preset-lint-consistent": "^6.0.0", + "remark-preset-lint-markdown-style-guide": "^6.0.0", + "remark-preset-lint-recommended": "^7.0.0" + } +}