Skip to content

Auto format CSS and JS syntax #159

Open
@ascott1

Description

@ascott1

Related to the discussion in cfgov-refresh #666 🤘

Newer tooling, such as Prettier allows for automated syntax formatting of JS and CSS. This reduces the need for syntax checks in code reviews and allows the reviews to be focused on the code itself. To quote @jimmynotjim:

being able to offload nonsense like this from each of our mental weights would be 💯

Prettier can be used in the following ways:

  • CLI tooling/npm scripts
  • Editor plugins
  • As a pre-commit/push hook with something like husky

The one potential blocker to using something like Prettier is that it has a limited configuration. In many ways this is a feature, but there may be ways that those differ from our current documented standards. The biggest one to jump out at me is our use of spaces within parens ( space ) vs (space).

A few questions for discussion:

  • Are we in favor of doing this? If so is Prettier the right tool for us?
  • Are there other differences from our documented standards? If so, are they worth updating for the ease of use Prettier provides?
  • What is the right way to integrate these into the team and individual projects? (my recommendation: encourage use of the editor extensions and set up pre-commit hooks)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions