-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USWDS-Site - Feature: Run prettier on accessibility tests, yml, and more #3120
base: main
Are you sure you want to change the base?
Conversation
Limiting markdown checks to accessibility tests for now.
Data is used in `/documentation/settings` page
!/**/accessibility-tests.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
For now, only running on accessibility tests. Need to scope out work to get all markdown files formatted without visual regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Running separately gives us faster feedback and allows us to clearly see formatting failures.
summary: Updated package name to `form-controls`. | ||
affectsGuidance: true | ||
githubPr: 1497 | ||
githubRepo: uswds-site |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
There shouldn't be any regressions in the memorable date changelog.
Preview link →
_data/changelogs/component-prose.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Changes to settings/components
can be verified in the settings page.
"pa11y-ci:sitemap-json": "pa11y-ci --json > pa11y-results.json --sitemap http://localhost:4000/sitemap.xml --sitemap-exclude '/*.pdf|next|together/'", | ||
"prettier:scss": "npx prettier --check './css/**/*.scss'", | ||
"prettier:js": "npx prettier --check './**/*.js'", | ||
"prettier:md": "npx prettier --check './**/accessibility-tests.md'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Intentionally leaving this specific to accessibility-tests until we can scope out the work to tackle all markdown files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I had just a few questions about the package.json scripts. Not sure any action is needed, just curious to hear why you set it up that way.
"prettier:fix": "concurrently 'npm run prettier:fix:scss' 'npm run prettier:fix:md' 'npm run prettier:fix:yml'", | ||
"prettier": "concurrently --maxProcesses 1 'npm run prettier:scss' 'npm run prettier:md' 'npm run prettier:yml'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Why are prettier:js
and prettier:fix:js
excluded from these bulk prettier scans?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"prettier:md": "npx prettier --check './**/accessibility-tests.md'", | ||
"prettier:yml": "npx prettier --check './_data/**/*.yml'", | ||
"prettier:fix:scss": "npx prettier --write './css/**/*.scss'", | ||
"prettier:fix:js": "npx prettier --write './**/*.js'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Running npm run prettier:fix:js
returned some changed files. Can we include those updates in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Are there any conflicts with prettier:fix
and our JS linting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slightly out of scope. I'm including because it's a small change, but in the future want to keep the PR focused on original issue.
Fixed in 21a1fa8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does look like there is a conflict between prettier and linting for JS files. I see this error now during linting:
/Users/amy.leadem/Dev/github/workspace/uswds-site/js/sidenav.js
19:53 error A space is required after '[' computed-property-spacing
19:55 error A space is required before ']' computed-property-spacing
/Users/amy.leadem/Dev/github/workspace/uswds-site/js/start.js
13:32 error A space is required after '[' computed-property-spacing
13:34 error A space is required before ']' computed-property-spacing
✖ 4 problems (4 errors, 0 warnings)
4 errors and 0 warnings potentially fixable with the `--fix` option.
Also noting that linting errors translate to passing checks in circleCI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverting in 3463c1a. This is outside of current scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mejiaj should the lint error there have flagged a circleCI failure? I'm a bit concerned that linting will be able to fail silently.
b05b111
to
21a1fa8
Compare
@amyleadem thanks for the review, ready for another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mejiaj Found a couple more things for your review.
- It looks like JS linting and prettier are in conflict, and it also looks like lint errors in CircleCI don't trigger the lint check to fail (See related comment for details).
- It looks like the lint script is a bit muddled because it runs prettier inside of it. Wondering if we can keep those separate. (See comment below)
Let me know if you have questions.
This reverts commit 21a1fa8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but before I approve I am curious to hear your thoughts on the silent lint failures in circleCI.
Summary
Additional prettier scripts to ensure we're using the correct formatting in more than just SCSS.
This feature adds check and fix scripts for:
Related issue
Closes #2868.
Problem statement
We're not running formatting checks on changelogs and a11y test findings. This causes inconsistencies and potential issues as we continue to develop.
Solution
This work adds:
prettier:scss
script to check for errors. The old one has been renamed toprettier:fix:scss
for consistency.lint_and_format
] that runs before build to check for formatting and linting errors.Major changes
1. New NPM scripts
Clearly separated scripts that check vs those that fix. I've also added concurrently to fix and check for issues. The check does not run in parallel so we can clearly distinguish the different types of issues.
uswds-site/package.json
Lines 62 to 70 in fbe41ee
The general prettier script is also run in CI.
2. New CI check
Running general prettier check in CI now so that we can resolve issues before merge. This job is separated from the others because it'd be nice to know as soon as possible rather than waiting until all other jobs have finished.
Separating also helps us clearly see the issue and migrate it more easily to GitHub actions in the future.
uswds-site/.circleci/config.yml
Lines 146 to 148 in fbe41ee
3. Running prettier on a11y tests
The issue says run prettier on markdown. But I've had to scope it down to only a11y tests, which was the main reason for creating the issue, due to regressions to markdown files that heavily rely on includes or adding classes.
Example of class issue
There are incompatibilities with the markdown formatter that Jekyll uses (
kramdown
) and the one Prettier is written for (CommonMark
).Issue
Because we use so much of this pattern and other possible regressions, I'm limiting the scope of the markdown checks.
Workaround
https://github.com/uswds/uswds-site/blob/fbe41ee6ae694439ebeca7c1b1a23bda83e0ebbb/.prettierignore#L21-L24
Summary
This is just one issue to illustrate the point. There are workarounds, but that increases the LOE to moderate or higher. In all, it would flag over 300 markdown formatting issues. Running the fix solves the prettier errors, but causes visual regressions that need to be carefully reviewed.
Testing and review
prettier:scss
prettier:js
. This will flag errors, but an optional test for now.prettier:md
. Scoped to a11y tests until we can break down and address other markdown issues.prettier:yml
. Checks against jekyll data, but could be extended to all YML files in the future.prettier
. This will check SCSS, MD, and YML one at a time.npm start
will now check for formatting issues, so we can catch during active development.CI before formatting fixes - Should fail
CI after fixes - Should pass
Footnotes
Markdown prettier check is limited to accessibility tests to avoid visual regressions in other pages. ↩