From f5c93e943ba34f735b61a9202ac4a057cd681795 Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Thu, 4 Apr 2024 23:00:43 +0800 Subject: [PATCH] ci: initial CI support with prettier Signed-off-by: You-Sheng Yang --- .github/linters/.markdown-lint.yml | 23 ++++++++++++++++++++ .github/linters/super-linter.env | 4 ++++ .github/workflows/linter.yml | 34 ++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 5 +++++ .prettierrc.json | 16 ++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/linters/super-linter.env create mode 100644 .github/workflows/linter.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierrc.json diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 000000000..2fe29e2bd --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,23 @@ +# Unordered list style +MD004: + style: dash + +# Line length +MD013: + line_length: 80 + tables: false + +# Ordered list item prefix +MD029: + style: one + +# Spaces after list markers +MD030: + ul_single: 1 + ol_single: 1 + ul_multi: 1 + ol_multi: 1 + +# Code block style +MD046: + style: fenced diff --git a/.github/linters/super-linter.env b/.github/linters/super-linter.env new file mode 100644 index 000000000..db1e0bfd3 --- /dev/null +++ b/.github/linters/super-linter.env @@ -0,0 +1,4 @@ +TYPESCRIPT_DEFAULT_STYLE=prettier +VALIDATE_ALL_CODEBASE=true +VALIDATE_JAVASCRIPT_STANDARD=false +VALIDATE_JSCPD=false diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 000000000..5f42518c9 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,34 @@ +name: Lint Codebase + +on: + pull_request: + branches: + - main + push: + branches: + - main + +permissions: + contents: read + packages: read + statuses: write + +jobs: + lint: + name: Lint Codebase + runs-on: ubuntu-latest + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Load super-linter configuration + run: cat .github/linters/super-linter.env >> "$GITHUB_ENV" + - name: Lint Codebase + id: super-linter + uses: super-linter/super-linter/slim@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..fd0454315 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-prettier + rev: 'v3.1.0' + hooks: + - id: prettier diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..a37814692 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,16 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": false, + "singleQuote": true, + "quoteProps": "as-needed", + "jsxSingleQuote": false, + "trailingComma": "none", + "bracketSpacing": true, + "bracketSameLine": true, + "arrowParens": "avoid", + "proseWrap": "always", + "htmlWhitespaceSensitivity": "css", + "endOfLine": "lf" +}