From 54c1413c30d09fc482da0b8a30d3841ac78c8b6e Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Mon, 4 Nov 2024 09:06:02 -0500 Subject: [PATCH 1/8] gh-workflow: Add Stylelint problem matcher to GitHub Actions, replacing the previous formatter approach. --- .github/problem-matchers/stylelint.json | 21 +++++++++++++++++++++ .github/workflows/lint.yaml | 11 ++++++++++- package.json | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/problem-matchers/stylelint.json diff --git a/.github/problem-matchers/stylelint.json b/.github/problem-matchers/stylelint.json new file mode 100644 index 00000000..39617b29 --- /dev/null +++ b/.github/problem-matchers/stylelint.json @@ -0,0 +1,21 @@ +{ + "problemMatcher": [ + { + "owner": "stylelint", + "pattern": [ + { + "regexp": "^([^\\s].*)$", + "file": 1 + }, + { + "regexp": "^\\s*(\\d+):(\\d+)\\s+(\\S+)\\s+(.+?)\\s+(\\S+)$", + "line": 1, + "column": 2, + "message": 4, + "code": 5, + "loop": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5f910277..24d67b3e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,4 +29,13 @@ jobs: with: node-version: 22 - run: "npm clean-install" - - run: "npm run lint:ci" + - name: "Set up Stylelint Problem Matcher" + run: "echo '::add-matcher::./.github/problem-matchers/stylelint.json'" + - name: "Run `lint:ci` script." + run: |- + # Disable ANSI color codes in Stylelint default "string" formatter + export NO_COLOR=1 + npm run lint:ci + - if: "always()" + name: "Remove Stylelint Problem Matcher" + run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json'" \ No newline at end of file diff --git a/package.json b/package.json index 886cf2a3..0e4cf879 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "lint:check": "npm-run-all --sequential --continue-on-error lint:check:*", "lint:check:css": "stylelint src/**/*.css", "lint:check:js": "eslint src webpack.*.js --max-warnings 0", - "lint:ci": "npm-run-all --sequential --continue-on-error lint:check:js \"lint:check:css -- --formatter github\"", + "lint:ci": "npm-run-all --sequential --continue-on-error lint:check:*", "lint:fix": "npm-run-all --parallel --continue-on-error \"lint:check:* -- --fix\"" }, "repository": { From 598af7abe62df36f27b3c0fa137e306748c6b778 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Mon, 4 Nov 2024 09:33:41 -0500 Subject: [PATCH 2/8] Add missing newlines to EOFs. --- .github/problem-matchers/stylelint.json | 2 +- .github/workflows/lint.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/problem-matchers/stylelint.json b/.github/problem-matchers/stylelint.json index 39617b29..193cc1a2 100644 --- a/.github/problem-matchers/stylelint.json +++ b/.github/problem-matchers/stylelint.json @@ -18,4 +18,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 24d67b3e..d54e50a5 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -38,4 +38,4 @@ jobs: npm run lint:ci - if: "always()" name: "Remove Stylelint Problem Matcher" - run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json'" \ No newline at end of file + run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json'" From 155b06721d7120806af56db23fadd9f412b8b5ba Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 21 Nov 2024 18:11:34 -0500 Subject: [PATCH 3/8] Remove script `lint:ci` and use `lint:check` in GH workflow - Apply suggestions from code review Co-authored-by: davemarco <83603688+davemarco@users.noreply.github.com> --- .github/workflows/lint.yaml | 2 +- package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d54e50a5..fa36fe97 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -35,7 +35,7 @@ jobs: run: |- # Disable ANSI color codes in Stylelint default "string" formatter export NO_COLOR=1 - npm run lint:ci + npm run lint:check - if: "always()" name: "Remove Stylelint Problem Matcher" run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json'" diff --git a/package.json b/package.json index 0e4cf879..224e4538 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "lint:check": "npm-run-all --sequential --continue-on-error lint:check:*", "lint:check:css": "stylelint src/**/*.css", "lint:check:js": "eslint src webpack.*.js --max-warnings 0", - "lint:ci": "npm-run-all --sequential --continue-on-error lint:check:*", "lint:fix": "npm-run-all --parallel --continue-on-error \"lint:check:* -- --fix\"" }, "repository": { From adc0e9e69eb9cc1093a6a81f22ca56611e929839 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 21 Nov 2024 18:14:11 -0500 Subject: [PATCH 4/8] Add `owner` when removing the matcher - Apply suggestions from code review --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fa36fe97..748de34d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -38,4 +38,4 @@ jobs: npm run lint:check - if: "always()" name: "Remove Stylelint Problem Matcher" - run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json'" + run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json owner=stylelint::'" From 77b8f39ef5b95223f3ce5b3741f959718bfd1dc3 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 21 Nov 2024 18:24:59 -0500 Subject: [PATCH 5/8] Extract a constant for the stylelint problem matcher path. --- .github/workflows/lint.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 748de34d..3e48263c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,6 +21,8 @@ concurrency: jobs: lint-check: runs-on: "ubuntu-latest" + env: + STYLELINT_MATCHER_PATH: "./.github/problem-matchers/stylelint.json" steps: - uses: "actions/checkout@v4" with: @@ -30,7 +32,7 @@ jobs: node-version: 22 - run: "npm clean-install" - name: "Set up Stylelint Problem Matcher" - run: "echo '::add-matcher::./.github/problem-matchers/stylelint.json'" + run: "echo '::add-matcher::${{env.STYLELINT_MATCHER_PATH}}'" - name: "Run `lint:ci` script." run: |- # Disable ANSI color codes in Stylelint default "string" formatter @@ -38,4 +40,4 @@ jobs: npm run lint:check - if: "always()" name: "Remove Stylelint Problem Matcher" - run: "echo '::remove-matcher::./.github/problem-matchers/stylelint.json owner=stylelint::'" + run: "echo '::remove-matcher::${{env.STYLELINT_MATCHER_PATH}}'" From 1edf8fc65a7590b287a9f77cc9dff8ff1fa2c773 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 21 Nov 2024 18:25:30 -0500 Subject: [PATCH 6/8] Update step name `lint:ci` -> `lint:check`. --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3e48263c..05e4114e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -33,7 +33,7 @@ jobs: - run: "npm clean-install" - name: "Set up Stylelint Problem Matcher" run: "echo '::add-matcher::${{env.STYLELINT_MATCHER_PATH}}'" - - name: "Run `lint:ci` script." + - name: "Run `lint:check` script." run: |- # Disable ANSI color codes in Stylelint default "string" formatter export NO_COLOR=1 From c684c8897968221360f88b9d6ee9b6c74a5121fe Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 21 Nov 2024 18:32:27 -0500 Subject: [PATCH 7/8] Add back `owner` into `remove-matcher`. --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 05e4114e..31d62972 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -40,4 +40,4 @@ jobs: npm run lint:check - if: "always()" name: "Remove Stylelint Problem Matcher" - run: "echo '::remove-matcher::${{env.STYLELINT_MATCHER_PATH}}'" + run: "echo '::remove-matcher::${{env.STYLELINT_MATCHER_PATH}} owner=stylelint::'" From 32d5ba55df459c27aa2af0c4835995e12ef55107 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 21 Nov 2024 18:45:03 -0500 Subject: [PATCH 8/8] Correct `remove-matcher` syntax. --- .github/workflows/lint.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 31d62972..e9d494a9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,6 +22,7 @@ jobs: lint-check: runs-on: "ubuntu-latest" env: + STYLELINT_MATCHER_OWNER: "stylelint" STYLELINT_MATCHER_PATH: "./.github/problem-matchers/stylelint.json" steps: - uses: "actions/checkout@v4" @@ -40,4 +41,4 @@ jobs: npm run lint:check - if: "always()" name: "Remove Stylelint Problem Matcher" - run: "echo '::remove-matcher::${{env.STYLELINT_MATCHER_PATH}} owner=stylelint::'" + run: "echo '::remove-matcher owner=${{env.STYLELINT_MATCHER_OWNER}}::'"