Skip to content

Commit 0990d34

Browse files
authored
Merge pull request #1860 from equalizedigital/william/no-issue/stylelint-manual-fixes
StyleLint: resolve remaining manual-fix findings
2 parents b2fcc98 + bd0a71d commit 0990d34

26 files changed

Lines changed: 2401 additions & 2206 deletions

.github/workflows/lint-css.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Lint CSS
2+
3+
on:
4+
# Run on direct pushes to integration branches and on all pull requests.
5+
push:
6+
branches:
7+
- develop
8+
- main
9+
- master
10+
- trunk
11+
pull_request:
12+
# Allow manually triggering the workflow.
13+
workflow_dispatch:
14+
15+
# Cancels all previous workflow runs for the same branch that have not yet completed.
16+
concurrency:
17+
# The concurrency group contains the workflow name and the branch name.
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
lint:
23+
runs-on: ubuntu-latest
24+
25+
name: "Lint: CSS"
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v3
30+
31+
- name: Cache Node.js modules
32+
id: cache-node-modules
33+
uses: actions/cache@v4
34+
with:
35+
path: node_modules
36+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-node_modules-
39+
# The lint stage doesn't run the unit tests or use code style, so no need for PHPUnit, WPCS or phpcompatibility.
40+
- name: 'Install NPM packages'
41+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
42+
run: npm ci --prefer-offline --no-audit --ignore-scripts
43+
44+
- name: Get only files changed in this PR
45+
id: changed-files
46+
uses: actions/github-script@v6
47+
with:
48+
script: |
49+
if (!context.payload.pull_request) {
50+
core.warning("No pull request context available. Skipping changed files retrieval.");
51+
core.setOutput('files', '');
52+
return '';
53+
}
54+
55+
const changedFiles = await github.paginate(
56+
github.rest.pulls.listFiles,
57+
{
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
pull_number: context.payload.pull_request.number,
61+
}
62+
);
63+
const cssFiles = changedFiles
64+
.filter(file => file.status !== 'removed')
65+
.map(file => file.filename)
66+
.filter(filename => filename.endsWith('.scss') || filename.endsWith('.css'))
67+
.join(' ');
68+
69+
core.setOutput('files', cssFiles);
70+
return cssFiles;
71+
72+
# If this is a PR then lint only css/scss changed in the PR, if not a PR then lint them all.
73+
- name: Run stylelint
74+
run: npx wp-scripts lint-style ${{ steps.changed-files.outputs.files || '' }}

.stylelintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build
2+
dist
3+
vendor
4+
coverage
5+
node_modules

.stylelintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "@wordpress/stylelint-config/scss-stylistic",
3+
"rules": {
4+
"selector-class-pattern": null,
5+
"selector-id-pattern": null,
6+
"scss/load-no-partial-leading-underscore": null
7+
}
8+
}

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
"dist": "npx webpack --mode production && composer install --no-dev && composer dump-autoload --no-dev -o && ./scripts/dist.sh && composer install",
1313
"dist:dotorg": "npm run dist:keep-build-folder",
1414
"dist:keep-build-folder": "npx webpack --mode production && composer install --no-dev && composer dump-autoload --no-dev -o && ./scripts/dist.sh --keep-build-folder",
15-
"lint": "./vendor/bin/phpcs && npm run lint:js",
15+
"lint": "./vendor/bin/phpcs && npm run lint:js && npm run lint:css",
1616
"lint-staged-precommit": "lint-staged",
1717
"lint:php": "./vendor/bin/phpcs",
1818
"lint:php:fix": "./vendor/bin/phpcbf",
1919
"lint:js": "wp-scripts lint-js",
2020
"lint:js:fix": "wp-scripts lint-js --fix",
21+
"lint:css": "wp-scripts lint-style",
22+
"lint:css:fix": "wp-scripts lint-style --fix",
2123
"test:php": "./scripts/setup-phpunit.sh",
2224
"test:php:run": "docker compose exec phpunit vendor/bin/phpunit",
2325
"test:php:coverage": "docker compose exec phpunit vendor/bin/phpunit --coverage-clover=./coverage/clover.xml --coverage-html=./coverage/html",
@@ -28,7 +30,8 @@
2830
},
2931
"lint-staged": {
3032
"*.php": "./vendor/bin/phpcs",
31-
"*.js": "wp-scripts lint-js"
33+
"*.js": "wp-scripts lint-js",
34+
"*.scss": "wp-scripts lint-style"
3235
},
3336
"files": [
3437
"LICENSE.txt",

0 commit comments

Comments
 (0)