From 0a1bd767c65e43949670a97b311a4f87a300af6a Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 13 Sep 2022 10:48:17 -0400 Subject: [PATCH] chore: Opt-in cleaned folders and CI for Prettier --- .github/workflows/markdown-lint.yml | 11 ++++---- .github/workflows/pr-check_markdownlint.yml | 31 +++++++++++++++++++-- .prettierignore | 13 +++++++++ package.json | 4 +-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index 42a4060656162f1..701c8e66ccd4b84 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -5,14 +5,16 @@ on: branches: - main paths: + - .github/workflows/markdown-lint.yml + - .github/workflows/markdownlint-problem-matcher.json - .markdownlint-cli2.jsonc + - .prettierignore + - .prettierrc.json - package.json - yarn.lock - - .github/workflows/markdown-lint.yml - - .github/workflows/markdownlint-problem-matcher.json jobs: - docs: + lint: runs-on: ubuntu-latest steps: @@ -25,8 +27,7 @@ jobs: cache: yarn - name: Install all yarn packages - run: | - yarn --frozen-lockfile + run: yarn --frozen-lockfile - name: Lint markdown files run: | diff --git a/.github/workflows/pr-check_markdownlint.yml b/.github/workflows/pr-check_markdownlint.yml index c6617d4a4e17b9b..961d2d46000a6e5 100644 --- a/.github/workflows/pr-check_markdownlint.yml +++ b/.github/workflows/pr-check_markdownlint.yml @@ -8,7 +8,7 @@ on: - "**/*.md" jobs: - docs: + cli2: runs-on: ubuntu-latest steps: @@ -36,11 +36,36 @@ jobs: cache: yarn - name: Install all yarn packages - run: | - yarn --frozen-lockfile + run: yarn --frozen-lockfile - name: Lint markdown files run: | echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json" files_to_lint="${{ env.DIFF_DOCUMENTS }}" yarn markdownlint-cli2 ${files_to_lint} + + prettier: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v29.0.5 + with: + files: "**/*.md" + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: "16" + cache: yarn + + - name: Install all yarn packages + run: yarn --frozen-lockfile + + - name: Prettier markdown files + run: | + files_to_lint="${{ steps.changed-files.outputs.all_changed_files }}" + yarn prettier -c ${files_to_lint} diff --git a/.prettierignore b/.prettierignore index 9359c3f3d3c18c9..681ec9fd8c88efa 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,16 @@ build/ # Ignore markdown files till full pass is made on each folder *.md + +# Opt-in folders that have prettier run on them +!/*.md +!/files/en-us/games/**/*.md +!/files/en-us/glossary/**/*.md +!/files/en-us/related/**/*.md +!/files/en-us/webassembly/**/*.md + +# Folders that have not fully run prettier for their code fences +# !/files/en-us/learn/**/*.md +# !/files/en-us/mdn/**/*.md +# !/files/en-us/mozilla/**/*.md +# !/files/en-us/web/**/*.md diff --git a/package.json b/package.json index 2373fab13ec2684..4184a95ba6c2893 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ "filecheck": "env-cmd --silent cross-env CONTENT_ROOT=files yari-filecheck --cwd=.", "fix:js": "prettier -w \"**/*.(m)?js\"", "fix:json": "prettier -w \"**/*.json(c)?\"", - "fix:md": "markdownlint-cli2-fix \"**/*.md\"", + "fix:md": "markdownlint-cli2-fix \"**/*.md\" && prettier -w \"**/*.md\"", "fix:yml": "prettier -w \"**/*.yml\"", "lint:js": "prettier -c \"**/*.(m)?js\"", "lint:json": "prettier -c \"**/*.json(c)?\"", - "lint:md": "markdownlint-cli2 \"**/*.md\"", + "lint:md": "markdownlint-cli2 \"**/*.md\" && prettier -c \"**/*.md\"", "lint:yml": "prettier -c \"**/*.yml\"", "prepare": "husky install", "start": "yarn up-to-date-check && env-cmd --silent cross-env CONTENT_ROOT=files REACT_APP_DISABLE_AUTH=true BUILD_OUT_ROOT=build yari-server",