Skip to content

Apply Prettier config to the content of docs/sources #1409

@oleiade

Description

@oleiade
Contributor

In the current version of the documentation published at https://k6.io/docs/, all the code examples are formatted using Prettier, according to the .prettierrc file at the project's root. When making a commit, if the code examples modification does not match the prettier formatting rules, a git hook blocks the commit.

With the switch to the new Hugo-based documentation, this workflow seems broken. I could also test and commit code examples not matching our prettier rules successfully (without the hook blocking it).

Having a common configuration for all our examples has been a good practice in keeping the code we present to users consistent, and we should work on bringing back the prettier checks as part of the workflow.

Activity

oleiade

oleiade commented on Nov 13, 2023

@oleiade
ContributorAuthor

Sharing a finding: prettier supports markdown natively with the --parser markdown command-line option. I've tested it over some of our documentation by intentionally making it not match our config, and it does what you would expect.

oleiade

oleiade commented on Nov 13, 2023

@oleiade
ContributorAuthor

More context: my understanding that commit hooks in the repository are currently managed by the husky tool, which is configured in the .husky folder of the repo.

Our husky config consists in calling the lint-staged tool.

oleiade

oleiade commented on Nov 13, 2023

@oleiade
ContributorAuthor

Adding the following to the .lintstagedrc file seems to help:

  "docs/sources/**/*.md": "prettier --write"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Tooling/GatsbyFixes that require working with the CI, styles, or site generatorType: BugSomething doesn't work how it should

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @heitortsergent@oleiade

        Issue actions

          Apply Prettier config to the content of `docs/sources` · Issue #1409 · grafana/k6-docs