From 56e4607f6c2a6538779f91735bfa31508a55a3ca Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Wed, 16 Jul 2025 11:00:25 -0700 Subject: [PATCH 01/12] initial change --- .github/workflows/test-pull-request.yml | 26 +++++-------------------- package.json | 6 +++++- src/pages/config.md | 2 +- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 115c3d00..1a01a672 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -8,7 +8,6 @@ name: Latest Pull Request # Documentation: # - Workflow: https://help.github.com/en/articles/workflow-syntax-for-github-actions -# - SuperLinter: https://github.com/github/super-linter # - Markdown linter: https://github.com/DavidAnson/markdownlint # - Link validation: https://github.com/remarkjs/remark-validate-links @@ -36,26 +35,6 @@ jobs: ########################## - name: Checkout Code uses: actions/checkout@v3 - with: - # Full git history is needed to get a proper list of changed files - # within `super-linter` - fetch-depth: 0 - - run: cat ".github/super-linter.env" >> "$GITHUB_ENV" - - ################################ - # Run Linters against code base # - ################################ - - name: Lint Code Base - # - # Use full version number to avoid cases when a next - # released version is buggy - # About slim image: https://github.com/github/super-linter#slim-image - uses: github/super-linter/slim@v4.10.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEFAULT_BRANCH: main - VALIDATE_ALL_CODEBASE: false - VALIDATE_GITHUB_ACTIONS: true - name: Setup Node v16 for Yarn v3 uses: actions/setup-node@v3 @@ -77,6 +56,11 @@ jobs: with: cmd: install + - name: Lint Markdown files + uses: borales/actions-yarn@v3 + with: + cmd: lint + - name: Check internal links uses: borales/actions-yarn@v3 with: diff --git a/package.json b/package.json index 141712b7..c422499c 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,9 @@ "build": "gatsby build", "serve": "gatsby serve", "clean": "gatsby clean", - "lint": "docker run --rm -e RUN_LOCAL=true --env-file '.github/super-linter.env' -v \"$PWD\":/tmp/lint github/super-linter:slim-v4.10.1", + "lint": "markdownlint src/**/*.md", + "lint:fix": "markdownlint --fix src/**/*.md", + "test:links": "node check-links.js", "buildNavigation": "node buildNavigation.js", "buildRedirections": "node buildRedirections.js", "renameFiles": "node renameFiles.js", @@ -48,6 +50,8 @@ "express": "5.1.0", "glob": "11.0.0", "markdown-link-check": "^3.13.7", + "markdownlint": "^0.35.0", + "markdownlint-cli": "^0.37.0", "remark-cli": "^11.0.0", "remark-validate-links": "^12.1.0" } diff --git a/src/pages/config.md b/src/pages/config.md index 1c935a2a..1bb8b7fa 100644 --- a/src/pages/config.md +++ b/src/pages/config.md @@ -3,7 +3,7 @@ - versions: - [v2.0](/index.md) selected - - [v1.4](https://github.com/AdobeDocs/dev-site) + - [v1.4](https://github.com/AdobeDocs/dev-site) - pages: - [Cat Analytics](/index.md) From 15b3b884c99dc10bb0a2fc0fea21a15645e35d36 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 17 Jul 2025 11:11:38 -0700 Subject: [PATCH 02/12] update --- .github/linters/.markdownlint.yml | 6 ++---- src/pages/test/test-lint-rules.md | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/pages/test/test-lint-rules.md diff --git a/.github/linters/.markdownlint.yml b/.github/linters/.markdownlint.yml index 7c89f2e2..1a9e870f 100644 --- a/.github/linters/.markdownlint.yml +++ b/.github/linters/.markdownlint.yml @@ -38,14 +38,12 @@ hr-style: true # Horizontal rule style list-indent: true # Inconsistent indentation for list items at the same level no-empty-links: true no-missing-space-atx: true # No space after hash on atx style heading -no-multiple-blanks: true # Multiple consecutive blank lines no-reversed-links: true no-space-in-code: true no-space-in-emphasis: true no-space-in-links: true -no-trailing-spaces: true +single-h1: { "front_matter_title" : "" } # Only one h1 heading per file +no-alt-text: true #require alt-text single-trailing-newline: true # Files should end with a single newline character strong-style: style: "consistent" -ul-style: - style: "consistent" diff --git a/src/pages/test/test-lint-rules.md b/src/pages/test/test-lint-rules.md new file mode 100644 index 00000000..a328a5d4 --- /dev/null +++ b/src/pages/test/test-lint-rules.md @@ -0,0 +1,25 @@ +# Test Lint Rules + +This file contains test cases for various markdown linting rules. + +## Test Case 1: Valid - Single H1 + +This file has exactly one h1 heading (`# Test Lint Rules`) which is valid according to the `no-multiple-h1` rule. + +## Test Case 2: Valid - Multiple H2+ Headings + +### This is an H3 heading + +#### This is an H4 heading + +##### This is an H5 heading + +Multiple h2-h6 headings are allowed. + +## Test Case 3: Invalid Example (Commented Out) + +The following would violate the no-multiple-h1 rule: + +# First H1 Heading + +his would cause a linting error because there are multiple h1 headings in the same file. From b3d62aa063f89b271c05cd800fd5069c176b5a77 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 17 Jul 2025 12:51:53 -0700 Subject: [PATCH 03/12] update markdownlint --- .github/linters/.markdownlint.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/linters/.markdownlint.yml b/.github/linters/.markdownlint.yml index 1a9e870f..40aa2c3d 100644 --- a/.github/linters/.markdownlint.yml +++ b/.github/linters/.markdownlint.yml @@ -21,15 +21,8 @@ default: false ################# # Rules by tags # ################# -blanks-around-fences: true # Fenced code blocks should be surrounded by blank lines -blanks-around-headings: true # Headings should be surrounded by blank lines -blanks-around-lists: true # Lists should be surrounded by blank lines -code-block-style: - style: "fenced" code-fence-style: style: "backtick" -emphasis-style: - style: "consistent" fenced-code-language: true # Fenced code blocks should have a language specified heading-start-left: true # Headings must start at the beginning of the line heading-style: @@ -41,9 +34,5 @@ no-missing-space-atx: true # No space after hash on atx style heading no-reversed-links: true no-space-in-code: true no-space-in-emphasis: true -no-space-in-links: true single-h1: { "front_matter_title" : "" } # Only one h1 heading per file no-alt-text: true #require alt-text -single-trailing-newline: true # Files should end with a single newline character -strong-style: - style: "consistent" From c0e48e556cbb94db38eee99b20a00a4a099c0a40 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 17 Jul 2025 14:13:43 -0700 Subject: [PATCH 04/12] update on cli2 --- .markdownlint-cli2.cjs | 15 +++++++++++++++ .markdownlint.yml | 1 - package.json | 7 ++----- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 .markdownlint-cli2.cjs delete mode 120000 .markdownlint.yml diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs new file mode 100644 index 00000000..930b30d7 --- /dev/null +++ b/.markdownlint-cli2.cjs @@ -0,0 +1,15 @@ +module.exports = { + "globs": ["**/*.md"], + "defaultSeverity": "error", + "configuration": { + "default": false, + "MD025": { "severity": "warning" }, // Multiple top-level headings = warning + }, + "frontMatter": { + "title": "title" + }, + "ignores": [ + "**/node_modules", + "**/dist" + ] +}; diff --git a/.markdownlint.yml b/.markdownlint.yml deleted file mode 120000 index d709e3e4..00000000 --- a/.markdownlint.yml +++ /dev/null @@ -1 +0,0 @@ -.github/linters/.markdownlint.yml \ No newline at end of file diff --git a/package.json b/package.json index c422499c..39e27d97 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,7 @@ "build": "gatsby build", "serve": "gatsby serve", "clean": "gatsby clean", - "lint": "markdownlint src/**/*.md", - "lint:fix": "markdownlint --fix src/**/*.md", + "lint": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.cjs", "test:links": "node check-links.js", "buildNavigation": "node buildNavigation.js", "buildRedirections": "node buildRedirections.js", @@ -49,9 +48,7 @@ "devDependencies": { "express": "5.1.0", "glob": "11.0.0", - "markdown-link-check": "^3.13.7", - "markdownlint": "^0.35.0", - "markdownlint-cli": "^0.37.0", + "markdownlint-cli2": "^0.18.1", "remark-cli": "^11.0.0", "remark-validate-links": "^12.1.0" } From b1d5e05fe471540a93e39746c85602471ae969c2 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 17 Jul 2025 14:19:35 -0700 Subject: [PATCH 05/12] test PR --- .github/workflows/test-pull-request.yml | 1 + .markdownlint.yml | 10 ++++++++ package.json | 2 +- src/pages/test/test-lint-rules.md | 32 +++++++++++++++++++++++-- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .markdownlint.yml diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 1a01a672..37de686c 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -60,6 +60,7 @@ jobs: uses: borales/actions-yarn@v3 with: cmd: lint + continue-on-error: true - name: Check internal links uses: borales/actions-yarn@v3 diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 00000000..c57831f9 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,10 @@ +--- +# Markdown Linter Configuration +# Only enabling the no-multiple-h1 rule as requested + +# Disable all rules by default +default: false + +# Only enable the rule we want to check +single-h1: + severity: warning diff --git a/package.json b/package.json index 39e27d97..d0f71c02 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "build": "gatsby build", "serve": "gatsby serve", "clean": "gatsby clean", - "lint": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.cjs", + "lint": "markdownlint src/**/*.md", "test:links": "node check-links.js", "buildNavigation": "node buildNavigation.js", "buildRedirections": "node buildRedirections.js", diff --git a/src/pages/test/test-lint-rules.md b/src/pages/test/test-lint-rules.md index a328a5d4..548249c2 100644 --- a/src/pages/test/test-lint-rules.md +++ b/src/pages/test/test-lint-rules.md @@ -18,8 +18,36 @@ Multiple h2-h6 headings are allowed. ## Test Case 3: Invalid Example (Commented Out) -The following would violate the no-multiple-h1 rule: +The following would violate the single-h1 rule: + + +## Test Case 4: Valid - Mixed Heading Levels + +### Subsection 1 +Content for subsection 1. + +### Subsection 2 +Content for subsection 2. + +#### Sub-subsection +More detailed content. + +## Test Case 5: Valid - No Additional H1 + +This file demonstrates that having exactly one h1 at the top is valid, and all other headings should be h2 or lower. + +### Summary + +- ✅ One h1 heading at the top +- ✅ Multiple h2-h6 headings allowed +- ⚠️ Multiple h1 headings would show as warnings (not errors) +- ❌ No h1 heading would also fail (if required by other rules) From 1d4c6939539ad30958854ffd3f26ba35f97348fe Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 17 Jul 2025 14:30:08 -0700 Subject: [PATCH 06/12] update --- .github/workflows/test-pull-request.yml | 2 +- .markdownlint-cli2.cjs | 11 ++++++- package.json | 3 +- src/pages/test/test-lint-levels.md | 38 +++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/pages/test/test-lint-levels.md diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 37de686c..96a37c1c 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -60,7 +60,7 @@ jobs: uses: borales/actions-yarn@v3 with: cmd: lint - continue-on-error: true + continue-on-error: false - name: Check internal links uses: borales/actions-yarn@v3 diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs index 930b30d7..d68c7b0e 100644 --- a/.markdownlint-cli2.cjs +++ b/.markdownlint-cli2.cjs @@ -3,7 +3,16 @@ module.exports = { "defaultSeverity": "error", "configuration": { "default": false, - "MD025": { "severity": "warning" }, // Multiple top-level headings = warning + // Rules that will fail PR validation (errors) + "MD009": true, // no-trailing-spaces + "MD012": true, // no-multiple-blanks + "MD013": true, // line-length + "MD041": true, // first-line-heading + + // Rules that will show warnings but not fail PR (warnings) + "MD025": { "severity": "warning" }, // single-h1 (multiple top-level headings) + "MD024": { "severity": "warning" }, // no-duplicate-heading + "MD026": { "severity": "warning" }, // no-trailing-punctuation-in-heading }, "frontMatter": { "title": "title" diff --git a/package.json b/package.json index d0f71c02..dc8e4881 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "build": "gatsby build", "serve": "gatsby serve", "clean": "gatsby clean", - "lint": "markdownlint src/**/*.md", + "lint": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.cjs", + "lint:check": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.cjs --fix", "test:links": "node check-links.js", "buildNavigation": "node buildNavigation.js", "buildRedirections": "node buildRedirections.js", diff --git a/src/pages/test/test-lint-levels.md b/src/pages/test/test-lint-levels.md new file mode 100644 index 00000000..180dfa0a --- /dev/null +++ b/src/pages/test/test-lint-levels.md @@ -0,0 +1,38 @@ +# Test Lint Rule Levels + +This file demonstrates different markdown linting rule levels. + +## Error Rules (Will Fail PR) + +### MD009 - No Trailing Spaces +This line has a trailing space: + +### MD012 - No Multiple Blanks + + +This line has multiple blank lines above it. + +### MD013 - Line Length +This is a very long line that exceeds the default line length limit and should trigger an error because it's too long and violates the line length rule. + +### MD041 - First Line Heading +This file starts with an h1 heading, which is correct. + +## Warning Rules (Will Show Warning but Pass PR) + +### MD025 - Single H1 (Multiple Top-Level Headings) +This file has one h1 heading at the top, which is correct. + +### MD024 - No Duplicate Heading +## Duplicate Heading +Some content here. +## Duplicate Heading +This duplicate heading should trigger a warning. + +### MD026 - No Trailing Punctuation in Heading +## Heading with trailing punctuation? + +## Summary + +- **Errors** (fail PR): trailing spaces, multiple blanks, long lines, missing first heading +- **Warnings** (pass PR): multiple h1s, duplicate headings, trailing punctuation in headings \ No newline at end of file From be5e72dcfa5d5335c1c08c58ec47f502cfed7e12 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 7 Aug 2025 10:37:57 -0700 Subject: [PATCH 07/12] test --- .github/workflows/test-pull-request.yml | 22 ++++++++++++++++++---- .markdownlint-cli2.cjs | 16 ++++++++-------- src/pages/test/test-lint-levels.md | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 96a37c1c..15bf97a4 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -57,10 +57,24 @@ jobs: cmd: install - name: Lint Markdown files - uses: borales/actions-yarn@v3 - with: - cmd: lint - continue-on-error: false + run: | + # Run linting and capture output + yarn lint 2>&1 | tee lint-output.txt + + # Check if there are any critical errors (MD009, MD012, MD013, MD041) + if grep -q "MD009\|MD012\|MD013\|MD041" lint-output.txt; then + echo "❌ Found critical errors - PR validation failed" + cat lint-output.txt + exit 1 + fi + + # Check for warning-level violations (MD025, MD024, MD026) + if grep -q "MD025\|MD024\|MD026" lint-output.txt; then + echo "⚠️ Found style warnings (these won't fail the PR):" + grep "MD025\|MD024\|MD026" lint-output.txt || true + fi + + echo "✅ Linting completed successfully" - name: Check internal links uses: borales/actions-yarn@v3 diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs index d68c7b0e..b020f881 100644 --- a/.markdownlint-cli2.cjs +++ b/.markdownlint-cli2.cjs @@ -4,15 +4,15 @@ module.exports = { "configuration": { "default": false, // Rules that will fail PR validation (errors) - "MD009": true, // no-trailing-spaces - "MD012": true, // no-multiple-blanks - "MD013": true, // line-length - "MD041": true, // first-line-heading - + "no-trailing-spaces": true, + "no-multiple-blanks": true, + "line-length": true, + "first-line-heading": true, + // Rules that will show warnings but not fail PR (warnings) - "MD025": { "severity": "warning" }, // single-h1 (multiple top-level headings) - "MD024": { "severity": "warning" }, // no-duplicate-heading - "MD026": { "severity": "warning" }, // no-trailing-punctuation-in-heading + "single-h1": true, // multiple top-level headings - will be handled in workflow + "no-duplicate-heading": true, // will be handled in workflow + "no-trailing-punctuation-in-heading": true, // will be handled in workflow }, "frontMatter": { "title": "title" diff --git a/src/pages/test/test-lint-levels.md b/src/pages/test/test-lint-levels.md index 180dfa0a..d8c4892e 100644 --- a/src/pages/test/test-lint-levels.md +++ b/src/pages/test/test-lint-levels.md @@ -35,4 +35,4 @@ This duplicate heading should trigger a warning. ## Summary - **Errors** (fail PR): trailing spaces, multiple blanks, long lines, missing first heading -- **Warnings** (pass PR): multiple h1s, duplicate headings, trailing punctuation in headings \ No newline at end of file +- **Warnings** (pass PR): multiple h1s, duplicate headings, trailing punctuation in headings From 39111b9f0fe5e340fd378c6984bf4949f40926fc Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 7 Aug 2025 14:02:42 -0700 Subject: [PATCH 08/12] update --- .github/linters/.markdownlint.yml | 38 ------------------------------- .markdownlint-cli2.cjs | 18 +++++++-------- .markdownlint.yml | 5 +++- 3 files changed, 13 insertions(+), 48 deletions(-) delete mode 100644 .github/linters/.markdownlint.yml diff --git a/.github/linters/.markdownlint.yml b/.github/linters/.markdownlint.yml deleted file mode 100644 index 40aa2c3d..00000000 --- a/.github/linters/.markdownlint.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -########################### -########################### -## Markdown Linter rules ## -########################### -########################### - -# Linter rules doc: -# - https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md -# -# Note: -# To comment out a single error: -# -# any violations you want -# -# - -# Default state for all rules -default: false - -################# -# Rules by tags # -################# -code-fence-style: - style: "backtick" -fenced-code-language: true # Fenced code blocks should have a language specified -heading-start-left: true # Headings must start at the beginning of the line -heading-style: - style: "atx" -hr-style: true # Horizontal rule style -list-indent: true # Inconsistent indentation for list items at the same level -no-empty-links: true -no-missing-space-atx: true # No space after hash on atx style heading -no-reversed-links: true -no-space-in-code: true -no-space-in-emphasis: true -single-h1: { "front_matter_title" : "" } # Only one h1 heading per file -no-alt-text: true #require alt-text diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs index b020f881..308ffaeb 100644 --- a/.markdownlint-cli2.cjs +++ b/.markdownlint-cli2.cjs @@ -1,18 +1,18 @@ module.exports = { "globs": ["**/*.md"], "defaultSeverity": "error", - "configuration": { + "configuration": { "default": false, // Rules that will fail PR validation (errors) - "no-trailing-spaces": true, - "no-multiple-blanks": true, - "line-length": true, - "first-line-heading": true, - + "MD009": true, // no-trailing-spaces + "MD012": true, // no-multiple-blanks + "MD013": true, // line-length + "MD041": true, // first-line-heading + // Rules that will show warnings but not fail PR (warnings) - "single-h1": true, // multiple top-level headings - will be handled in workflow - "no-duplicate-heading": true, // will be handled in workflow - "no-trailing-punctuation-in-heading": true, // will be handled in workflow + "MD025": true, // single-h1 (multiple top-level headings) - will be handled in workflow + "MD024": true, // no-duplicate-heading - will be handled in workflow + "MD026": true, // no-trailing-punctuation-in-heading - will be handled in workflow }, "frontMatter": { "title": "title" diff --git a/.markdownlint.yml b/.markdownlint.yml index c57831f9..7126ff64 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -6,5 +6,8 @@ default: false # Only enable the rule we want to check -single-h1: +single-h1: + severity: error + +MD013: severity: warning From 6e0665050c155b092f679f885fae00d2377c7e76 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 7 Aug 2025 14:06:34 -0700 Subject: [PATCH 09/12] update --- .github/workflows/test-pull-request.yml | 19 ++----------------- lint-check.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 lint-check.sh diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index d968e76a..c8366ba2 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -60,23 +60,8 @@ jobs: - name: Lint Markdown files run: | - # Run linting and capture output - yarn lint 2>&1 | tee lint-output.txt - - # Check if there are any critical errors (MD009, MD012, MD013, MD041) - if grep -q "MD009\|MD012\|MD013\|MD041" lint-output.txt; then - echo "❌ Found critical errors - PR validation failed" - cat lint-output.txt - exit 1 - fi - - # Check for warning-level violations (MD025, MD024, MD026) - if grep -q "MD025\|MD024\|MD026" lint-output.txt; then - echo "⚠️ Found style warnings (these won't fail the PR):" - grep "MD025\|MD024\|MD026" lint-output.txt || true - fi - - echo "✅ Linting completed successfully" + chmod +x lint-check.sh + ./lint-check.sh - name: Check internal links uses: borales/actions-yarn@v3 diff --git a/lint-check.sh b/lint-check.sh new file mode 100644 index 00000000..3ca8bb86 --- /dev/null +++ b/lint-check.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Run linting and capture output +yarn lint 2>&1 | tee lint-output.txt + +# Check if there are any critical errors (MD009, MD012, MD013, MD041) +if grep -q "MD009\|MD012\|MD013\|MD041" lint-output.txt; then + echo "❌ Found critical errors - PR validation failed" + cat lint-output.txt + exit 1 +fi + +# Check for warning-level violations (MD025, MD024, MD026) +if grep -q "MD025\|MD024\|MD026" lint-output.txt; then + echo "⚠️ Found style warnings (these won't fail the PR):" + grep "MD025\|MD024\|MD026" lint-output.txt || true +fi + +echo "✅ Linting completed successfully" \ No newline at end of file From 4951a745a86c681082aef3e26d40a3ae3c0a8084 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 7 Aug 2025 14:10:12 -0700 Subject: [PATCH 10/12] update --- .github/workflows/test-pull-request.yml | 4 +--- lint-check.sh | 19 --------------- scripts/lint-check.js | 32 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 22 deletions(-) delete mode 100644 lint-check.sh create mode 100644 scripts/lint-check.js diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index c8366ba2..0aa77b0d 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -59,9 +59,7 @@ jobs: cmd: install - name: Lint Markdown files - run: | - chmod +x lint-check.sh - ./lint-check.sh + run: node scripts/lint-check.js - name: Check internal links uses: borales/actions-yarn@v3 diff --git a/lint-check.sh b/lint-check.sh deleted file mode 100644 index 3ca8bb86..00000000 --- a/lint-check.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Run linting and capture output -yarn lint 2>&1 | tee lint-output.txt - -# Check if there are any critical errors (MD009, MD012, MD013, MD041) -if grep -q "MD009\|MD012\|MD013\|MD041" lint-output.txt; then - echo "❌ Found critical errors - PR validation failed" - cat lint-output.txt - exit 1 -fi - -# Check for warning-level violations (MD025, MD024, MD026) -if grep -q "MD025\|MD024\|MD026" lint-output.txt; then - echo "⚠️ Found style warnings (these won't fail the PR):" - grep "MD025\|MD024\|MD026" lint-output.txt || true -fi - -echo "✅ Linting completed successfully" \ No newline at end of file diff --git a/scripts/lint-check.js b/scripts/lint-check.js new file mode 100644 index 00000000..faf47dce --- /dev/null +++ b/scripts/lint-check.js @@ -0,0 +1,32 @@ +const { execSync } = require('child_process'); + +try { + console.log('🔍 Running markdown linting...'); + + // Run linting and capture output + const lintOutput = execSync('yarn lint 2>&1', { encoding: 'utf8' }); + + console.log('📋 Lint output:'); + console.log(lintOutput); + + // Check if there are any critical errors (MD009, MD012, MD013, MD041) + const criticalErrors = lintOutput.match(/MD009|MD012|MD013|MD041/g); + if (criticalErrors && criticalErrors.length > 0) { + console.log('❌ Found critical errors - PR validation failed'); + console.log('Critical errors found:', criticalErrors); + process.exit(1); + } + + // Check for warning-level violations (MD025, MD024, MD026) + const warnings = lintOutput.match(/MD025|MD024|MD026/g); + if (warnings && warnings.length > 0) { + console.log('⚠️ Found style warnings (these won\'t fail the PR):'); + console.log('Warnings found:', warnings); + } + + console.log('✅ Linting completed successfully'); +} catch (error) { + console.log('❌ Linting failed:', error.message); + console.log('Error details:', error); + process.exit(1); +} \ No newline at end of file From 24d02399e67419ebc0ffc6e4506edda2738da30b Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 7 Aug 2025 14:13:37 -0700 Subject: [PATCH 11/12] update --- scripts/lint-check.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/lint-check.js b/scripts/lint-check.js index faf47dce..d370ec3c 100644 --- a/scripts/lint-check.js +++ b/scripts/lint-check.js @@ -2,9 +2,15 @@ const { execSync } = require('child_process'); try { console.log('🔍 Running markdown linting...'); + console.log('📦 Current directory:', process.cwd()); + console.log('🔧 Yarn version:', execSync('yarn --version', { encoding: 'utf8' }).trim()); - // Run linting and capture output - const lintOutput = execSync('yarn lint 2>&1', { encoding: 'utf8' }); + // Run linting and capture output with timeout + console.log('🚀 Executing: yarn lint'); + const lintOutput = execSync('yarn lint 2>&1', { + encoding: 'utf8', + timeout: 60000 // 60 second timeout + }); console.log('📋 Lint output:'); console.log(lintOutput); From c43aa04ee7793df1bf147e0e2101104f26e77418 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Thu, 7 Aug 2025 14:23:10 -0700 Subject: [PATCH 12/12] update --- .github/workflows/test-pull-request.yml | 2 + .markdownlint-cli2.cjs | 4 +- package.json | 2 +- scripts/lint-check.js | 113 ++++++++++++++++++++---- 4 files changed, 101 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 0aa77b0d..cda686f3 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -60,6 +60,8 @@ jobs: - name: Lint Markdown files run: node scripts/lint-check.js + env: + YARN_ENABLE_IMMUTABLE_INSTALLS: false - name: Check internal links uses: borales/actions-yarn@v3 diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs index 308ffaeb..9c944c38 100644 --- a/.markdownlint-cli2.cjs +++ b/.markdownlint-cli2.cjs @@ -1,12 +1,12 @@ module.exports = { "globs": ["**/*.md"], "defaultSeverity": "error", - "configuration": { + "configuration": { "default": false, // Rules that will fail PR validation (errors) "MD009": true, // no-trailing-spaces "MD012": true, // no-multiple-blanks - "MD013": true, // line-length + "MD013": false, // line-length - disabled for now due to potential issues "MD041": true, // first-line-heading // Rules that will show warnings but not fail PR (warnings) diff --git a/package.json b/package.json index dc8e4881..cac2bc24 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "devDependencies": { "express": "5.1.0", "glob": "11.0.0", - "markdownlint-cli2": "^0.18.1", + "markdownlint-cli2": "^0.19.0", "remark-cli": "^11.0.0", "remark-validate-links": "^12.1.0" } diff --git a/scripts/lint-check.js b/scripts/lint-check.js index d370ec3c..d1461e70 100644 --- a/scripts/lint-check.js +++ b/scripts/lint-check.js @@ -1,33 +1,112 @@ -const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +// Custom markdown linting implementation +function customLintMarkdown() { + console.log('🔧 Running custom markdown linting...'); + const errors = []; + const warnings = []; + + // Find all markdown files + const markdownFiles = []; + function findMarkdownFiles(dir) { + try { + const files = fs.readdirSync(dir); + for (const file of files) { + const filePath = path.join(dir, file); + const stat = fs.statSync(filePath); + if (stat.isDirectory() && !file.startsWith('.') && file !== 'node_modules' && file !== 'dist') { + findMarkdownFiles(filePath); + } else if (file.endsWith('.md')) { + markdownFiles.push(filePath); + } + } + } catch (err) { + // Skip directories we can't read + } + } + + findMarkdownFiles('.'); + console.log(`📁 Found ${markdownFiles.length} markdown files to lint`); + + for (const file of markdownFiles) { + try { + const content = fs.readFileSync(file, 'utf8'); + const lines = content.split('\n'); + + // Check for trailing spaces (MD009) + for (let i = 0; i < lines.length; i++) { + if (lines[i].endsWith(' ')) { + errors.push(`MD009: ${file}:${i + 1}: Trailing spaces`); + } + } + + // Check for multiple blank lines (MD012) + let blankLineCount = 0; + for (let i = 0; i < lines.length; i++) { + if (lines[i].trim() === '') { + blankLineCount++; + if (blankLineCount > 1) { + errors.push(`MD012: ${file}:${i + 1}: Multiple blank lines`); + } + } else { + blankLineCount = 0; + } + } + + // Check for first line heading (MD041) - but be more lenient + if (lines.length > 0) { + const firstLine = lines[0].trim(); + if (firstLine && !firstLine.startsWith('#') && !firstLine.startsWith('---') && !firstLine.startsWith('&1', { - encoding: 'utf8', - timeout: 60000 // 60 second timeout - }); + // Use custom linting implementation + const customResult = customLintMarkdown(); console.log('📋 Lint output:'); - console.log(lintOutput); + if (customResult.errors.length > 0) { + console.log('❌ Critical errors found:'); + customResult.errors.forEach(error => console.log(error)); + } + + if (customResult.warnings.length > 0) { + console.log('⚠️ Warnings found:'); + customResult.warnings.forEach(warning => console.log(warning)); + } - // Check if there are any critical errors (MD009, MD012, MD013, MD041) - const criticalErrors = lintOutput.match(/MD009|MD012|MD013|MD041/g); - if (criticalErrors && criticalErrors.length > 0) { + // Check if there are any critical errors + if (customResult.errors.length > 0) { console.log('❌ Found critical errors - PR validation failed'); - console.log('Critical errors found:', criticalErrors); + console.log(`Total critical errors: ${customResult.errors.length}`); process.exit(1); } - // Check for warning-level violations (MD025, MD024, MD026) - const warnings = lintOutput.match(/MD025|MD024|MD026/g); - if (warnings && warnings.length > 0) { + if (customResult.warnings.length > 0) { console.log('⚠️ Found style warnings (these won\'t fail the PR):'); - console.log('Warnings found:', warnings); + console.log(`Total warnings: ${customResult.warnings.length}`); } console.log('✅ Linting completed successfully');