Task: Set up codestyle guidelines and automated tooling #190
Labels
backend
documentation
Improvements or additions to documentation
front-end
good first issue
Good for newcomers
Set up codestyle guidelines and automated tooling
As a developer, I want my environment to automatically style my code according to the project conventions, so that I can easily maintain project-wide consistency in code style.
Additional notes/thoughts
As for the specific prettier configuration that should be used... the defaults should be fine for the most part. If in doubt, look for an example in the repo. Otherwise, look for best practices in popular projects in the same tech ecosystem.
Prettier is a gold standard for this sort of thing. A unified prettier config should be enforced for all developers working on the project. Additionally, it is common practice to setup a git hook that runs the prettier checks to make sure that the repo is consistently maintaining the code style. It's fairly common for developers to set their IDE to autoformat using the prettier config on save, so there isn't an avalanche of violations when the git hook runs. I think this can be enforced in the workspace settings (which can be manually overridden by developers if they have personal preferences).
simple-git-hooks
is a package that does as the name suggests: drastically reduces the amount of configuration required to get a basic git hook setup for pre-commit, etc.Getting the prettier config setup to also format Tailwind class strings can be a bit tricky as there is conflicting info on the web last time I checked, but is definitely worth it for the added layer of consistency in the sorted classnames. Combine that with separating groups of classes onto separate lines in separate strings and it's just 🤌. Making a
cn
function using clsx and tailwindMerge is a good way to do that cleanly (see shadcn docs for an example).Definition of Done
190-setup-prettier-tooling
or similar)develop
branchTests pass on CIDeployed to staging environmentAcceptance Criteria
Solution Tasks
Set up a Prettier configuration file with the desired settings.
.prettierrc
file in the root directory.Configure VSCode workspace settings to recommend necessary plugins, including Prettier.
.vscode
folder withextensions.json
to recommend Prettier and other necessary extensions.settings.json
file in the.vscode
folder to enforce Prettier formatting on save.Install and configure
simple-git-hooks
to set up pre-commit hooks for running Prettier checks.simple-git-hooks
to the project dependencies.pre-commit
hook script to run Prettier checks on staged files.package.json
to usesimple-git-hooks
.Ensure that Tailwind class strings are formatted correctly by configuring Prettier with the necessary plugins and settings.
prettier-plugin-tailwindcss
and add it to the Prettier configuration.Implement a
cn
function usingclsx
andtailwindMerge
for managing Tailwind classnames cleanly.clsx
andtailwind-merge
to the project dependencies.cn
that combines and merges classnames usingclsx
andtailwind-merge
.Update environment setup documentation to include instructions for setting up the Prettier configuration and git hooks.
EnvironmentSetup.md
file.Ensure all team members are aware of the new guidelines and tooling by conducting a knowledge-sharing session.
References
NOTE: The version of Copilot integrated with GitHub.com assisted with fleshing out the enumeration aspects of this ticket. So if anything looks off, just drop a comment.
The text was updated successfully, but these errors were encountered: