From 0586dfbcec118e693c21793d906a579ce765a130 Mon Sep 17 00:00:00 2001 From: Phoenix Pereira <47909638+phoenixpereira@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:30:23 +1030 Subject: [PATCH] ci: Add linting and formatting checks workflow (#18) --- .github/workflows/ci-dev-pr.yml | 10 ++++++++++ .github/workflows/lint-and-format.yml | 28 +++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 39 insertions(+) create mode 100644 .github/workflows/ci-dev-pr.yml create mode 100644 .github/workflows/lint-and-format.yml diff --git a/.github/workflows/ci-dev-pr.yml b/.github/workflows/ci-dev-pr.yml new file mode 100644 index 0000000..e88a316 --- /dev/null +++ b/.github/workflows/ci-dev-pr.yml @@ -0,0 +1,10 @@ +name: Development - Pull Request +on: + pull_request_target: + branches: + - main + +jobs: + lint-format: + name: Linting and Formatting Checks + uses: ./.github/workflows/lint-and-format.yml diff --git a/.github/workflows/lint-and-format.yml b/.github/workflows/lint-and-format.yml new file mode 100644 index 0000000..c40177b --- /dev/null +++ b/.github/workflows/lint-and-format.yml @@ -0,0 +1,28 @@ +name: Linting and Formatting Checks +on: + workflow_call: + +jobs: + es-lint: + name: ESLint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9 + - run: pnpm install + - run: pnpm run lint + + prettier: + name: Prettier + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9 + - run: pnpm install + - run: pnpm run format:check diff --git a/package.json b/package.json index 1d66e15..6d99ff1 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "format": "prettier --write \"**/*.{js,ts,tsx,css,md,cjs,mjs,json,html}\"", + "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,css,json,mjs,cjs,yml,yaml}\"", "test": "vitest" }, "dependencies": {