Skip to content

Commit fd75b28

Browse files
authored
VACMS-3629: automatically lint custom (s)css (#3630)
* Automatically lint all custom (s)css * Update all custom (s)css to pass linting rules * Update composer.json * Use github actions to run stylelint instead of yaml-tests * [docs] Update code review doc * sudo make me a sandwich * Run stylelint as pre-commit check if lando is available * Ignore pushes to master branch for stylelint checks * [docs] Add code style IDE plugin documentation * Commit broken style to verify gh actions test * Use reviewdog with stylelint * Fix CSS style issues * Update to only show errors from the current PR
1 parent e8c81a1 commit fd75b28

32 files changed

+2537
-263
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: stylelint-modules
2+
on: [pull_request]
3+
jobs:
4+
stylelint:
5+
name: runner / stylelint
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v1
9+
- name: stylelint
10+
11+
# TODO: update to use reviewdog/action-stylelint@v1 when possible.
12+
uses: acrollet/action-stylelint@master
13+
with:
14+
fail_on_error: true
15+
github_token: ${{ secrets.github_token }}
16+
packages: 'stylelint-config-sass-guidelines stylelint-order'
17+
reporter: github-pr-review
18+
stylelint_config: '.stylelintrc'
19+
stylelint_input: 'docroot/modules/custom/**/*.css'
20+
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: stylelint-themes
2+
on: [pull_request]
3+
jobs:
4+
stylelint:
5+
name: runner / stylelint
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v1
9+
- name: stylelint
10+
11+
# TODO: update to use reviewdog/action-stylelint@v1 when possible.
12+
uses: acrollet/action-stylelint@master
13+
with:
14+
fail_on_error: true
15+
github_token: ${{ secrets.github_token }}
16+
packages: 'stylelint-config-sass-guidelines stylelint-order'
17+
reporter: github-pr-review
18+
stylelint_config: '.stylelintrc'
19+
stylelint_input: 'docroot/themes/custom/**/*.scss'
20+

.stylelintrc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"extends": "stylelint-config-sass-guidelines",
3+
"plugins": [
4+
"stylelint-order"
5+
],
6+
"rules": {
7+
"order/order": [
8+
"custom-properties",
9+
"declarations"
10+
],
11+
"order/properties-alphabetical-order": true,
12+
"max-nesting-depth": 5,
13+
"property-no-vendor-prefix": null,
14+
"selector-class-pattern": null,
15+
"selector-max-compound-selectors": 7,
16+
"selector-max-id": 1,
17+
"selector-no-qualifying-type": [
18+
true,
19+
{
20+
"ignore": [
21+
"class"
22+
]
23+
}
24+
]
25+
}
26+
}

READMES/code-review.md

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ The following automated code tools must pass before a Pull Request can be merged
8888

8989
* PHPCS
9090
* PHPMD
91+
* stylelint
9192

9293
## Definition of Done
9394

READMES/local.md

+11
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ This occurs because Drupal checks and hardens file permissions under the setting
8585
8686
```$settings['skip_permissions_hardening'] = TRUE;```
8787
88+
## IDE plugins
89+
There are plugins available to provide in-line style checking according to project standards.
90+
91+
### PHPCS
92+
- [PhpStorm](https://www.jetbrains.com/help/phpstorm/using-php-code-sniffer.html)
93+
- [VS Code](https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs)
94+
95+
### Stylelint
96+
- [PhpStorm](https://www.jetbrains.com/help/phpstorm/using-stylelint-code-quality-tool.html)
97+
- [VS Code](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint)
98+
8899
## Scripts
89100
There are some scripts created to help with managing the Drupal site locally.
90101

composer.json

+12
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,18 @@
395395
"va:proxy:sshuttle": [
396396
"sudo -E sshuttle -r [email protected] -e 'ssh -A ' 10.0.0.0/8"
397397
],
398+
"va:test:lint-css-all": [
399+
"npm install",
400+
"npm run stylelint-modules && npm run stylelint-themes"
401+
],
402+
"va:test:module-lint-css": [
403+
"npm install",
404+
"npm run stylelint-modules"
405+
],
406+
"va:test:theme-lint-scss": [
407+
"npm install",
408+
"npm run stylelint-themes"
409+
],
398410
"va:test:accessibility": [
399411
"npm install --only=production",
400412
"npm test"
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#block-sitealert {
2+
bottom: 0;
3+
box-sizing: border-box;
4+
left: 0;
25
position: fixed;
3-
bottom: 0px;
4-
left: 0px;
56
width: 100%;
67
z-index: 500;
7-
box-sizing: border-box;
88
}
99

1010
#block-sitealert div.site-alert div.severity-low,
1111
#block-sitealert div.site-alert div.severity-medium,
1212
#block-sitealert div.site-alert div.severity-high {
13-
margin-bottom: 0;
1413
background-image: none;
15-
color: black;
14+
color: #000;
15+
margin-bottom: 0;
1616
}
1717

1818
#block-sitealert div.site-alert div.severity-low {
@@ -24,19 +24,19 @@
2424
}
2525

2626
#block-sitealert div.site-alert div.severity-high {
27-
position: fixed;
28-
right: 0;
29-
bottom: 0;
30-
left: 0;
31-
height: 100vh;
3227
background-color: rgb(255, 241, 210);
3328
background-color: rgba(255, 241, 210, 0.9);
29+
bottom: 0;
30+
height: 100vh;
31+
left: 0;
32+
position: fixed;
33+
right: 0;
3434
z-index: 800;
3535
}
3636

37-
#block-sitealert div.site-alert div.severity-high div.text {
37+
#block-sitealert div.severity-high div.text {
3838
background-color: rgb(255, 241, 210);
39-
margin-top: 50vh;
4039
margin-left: 25%;
4140
margin-right: 25%;
41+
margin-top: 50vh;
4242
}

docroot/modules/custom/va_gov_user/css/sections_accordion.css

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
}
66

77
.item-list ul.sections .item-list ul {
8-
background-color: #ffffff;
8+
background-color: #fff;
99
margin: 0;
1010
padding: 0 0 0 2em;
1111
}
@@ -16,7 +16,7 @@
1616

1717
.item-list > ul.sections > li {
1818
border: 1px solid #aeb0b5;
19-
border-bottom: none;
19+
border-bottom: hidden;
2020
padding: 0;
2121
position: relative;
2222
}
@@ -40,11 +40,11 @@
4040
}
4141

4242
ul.sections li .toggle {
43+
background-color: transparent;
4344
background-image: url('../images/chevron-disc-down.svg');
44-
background-size: 1rem;
45-
background-position: 0.75rem .75rem;
45+
background-position: 0.75rem 0.75rem;
4646
background-repeat: no-repeat;
47-
background-color: transparent;
47+
background-size: 1rem;
4848
border: 0;
4949
cursor: pointer;
5050
display: block;

docroot/themes/custom/vagovadmin/assets/css/proofing.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docroot/themes/custom/vagovadmin/assets/css/proofing.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docroot/themes/custom/vagovadmin/assets/css/styles.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docroot/themes/custom/vagovadmin/assets/css/styles.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docroot/themes/custom/vagovadmin/assets/css/styles.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docroot/themes/custom/vagovadmin/assets/css/styles.min.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docroot/themes/custom/vagovadmin/assets/css/user_guides.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)