Skip to content
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 - Prettier should run on .md files. #3037

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

cathybaptista
Copy link
Contributor

@cathybaptista cathybaptista commented Dec 30, 2024

Summary

We were ignoring running prettier on markdown files. This can cause inconsistencies and errors when writing MD/Frontmatter.

Example: 1c6453d

Related issue

Note comment:

#2868 (comment)

These are links to these files, there weren't any problems running prettier

pages/design-principles/overview.md (before)
pages/design-principles/overview.md (after)

https://github.com/uswds/uswds-site/blob/main/pages/documentation/maturity-model.md (before)
https://github.com/uswds/uswds-site/blob/cb-enable-prettier-on-markdown/pages/documentation/maturity-model.md (after)

Closes #2868

Problem statement

By not running prettier against .md files (in .prettierignore), we are not ensuring these files are subject to coding standards and proper formatting.

Solution

  1. Remove .md from .prettierignore.
  2. Create two new NPM script to check & fix.
  3. Create CI test for linting and formatting.
    Fix issues.

Major changes

Added new script to config.yml:

  • run:
    name: Check formatting
    command: npm run prettier:check

Prettier check in package.json now checks .md files

lint in package.json runs "npx gulp lintJS lintSass && npm run prettier",

run prettier runs both prettier:md && prettier:scss

Do not run prettier on the vendor directory since we don't manage those md files.

Pipeline before running prettier:

image

Pipeline after running prettier:

image

Testing and review

  1. Pull the branch.
  2. Run prettier.
  3. Notice the changes to the markdown files.
  4. Commit the changed files and push.
  5. Make sure the pipeline doesn't fail because of prettier.

@cathybaptista cathybaptista force-pushed the cb-enable-prettier-on-markdown branch from 3a82e12 to 89e0ace Compare January 31, 2025 15:45
@cathybaptista cathybaptista changed the title cb: updating circleci and package.json to allow CI of md files. USWDS-Site - Prettier should run on .md files. Jan 31, 2025
@cathybaptista cathybaptista marked this pull request as ready for review January 31, 2025 19:11
@cathybaptista cathybaptista requested a review from a team as a code owner January 31, 2025 19:11
@cathybaptista cathybaptista force-pushed the cb-enable-prettier-on-markdown branch from e429e0f to 89e0ace Compare January 31, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USWDS-Site - Feature: Enable prettier on Markdown
2 participants