diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..3fb2837d4 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,29 @@ +name: Format + +on: + pull_request: + +jobs: + commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v2 + with: + configFile: .commitlintrc.json + helpURL: https://docs.pancakeswap.finance/code/contributing#committing + code: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v2.1.2 + with: + node-version: 14.x + - name: Install dependencies + run: yarn install + - name: Run check + run: yarn format:check diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ebbe71b0e..62193b52e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,16 +4,6 @@ on: pull_request: jobs: - commitlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: wagoid/commitlint-github-action@v2 - with: - configFile: .commitlintrc.json - helpURL: https://docs.pancakeswap.finance/code/contributing#committing eslint: runs-on: ubuntu-latest diff --git a/package.json b/package.json index 61909d747..edae92e38 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "scripts": { "build": "rm -rf ./dist && rollup -c && tsc -d --emitDeclarationOnly --declarationDir dist", "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'", - "format": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'", + "format:check": "prettier --check --loglevel error 'src/**/*.{js,jsx,ts,tsx}'", + "format:write": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook", "test": "jest", @@ -21,7 +22,7 @@ }, "husky": { "hooks": { - "pre-commit": "yarn format", + "pre-commit": "yarn format:write", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } },