diff --git a/.github/workflows/pr-check_markdownlint.yml b/.github/workflows/pr-check_markdownlint.yml index a404ffb6ff9b85f..cc8f3555da8077b 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: @@ -18,8 +18,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v29.0.9 with: - files: | - **/*.md + files: "**/*.md" - name: Setup Node.js environment uses: actions/setup-node@v3 @@ -28,11 +27,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="${{ steps.changed-files.outputs.all_changed_files }}" 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 3b7b9b02221f5f2..8e9c1363eb75672 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",