Task: Set up codestyle guidelines and automated tooling #190
Labels
No labels
accessibility
api
auth.js
backend
copy
database
defect
dependencies
design
discussion
documentation
duplicate
enhancement
epic
feature
front-end
good first issue
help wanted
invalid
next.js
noscript
on hold
operations
optimization
postgresql
prisma
prototype
question
react
spike
stale
story
tailwind
vulnerability
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
SSE/WebsiteTheSSEquel#190
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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-hooksis 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
cnfunction using clsx and tailwindMerge is a good way to do that cleanly (see shadcn docs for an example).Definition of Done
190-setup-prettier-toolingor similar)developbranchTests pass on CIDeployed to staging environmentAcceptance Criteria
Solution Tasks
Set up a Prettier configuration file with the desired settings.
.prettierrcfile in the root directory.Configure VSCode workspace settings to recommend necessary plugins, including Prettier.
.vscodefolder withextensions.jsonto recommend Prettier and other necessary extensions.settings.jsonfile in the.vscodefolder to enforce Prettier formatting on save.Install and configure
simple-git-hooksto set up pre-commit hooks for running Prettier checks.simple-git-hooksto the project dependencies.pre-commithook script to run Prettier checks on staged files.package.jsonto usesimple-git-hooks.Ensure that Tailwind class strings are formatted correctly by configuring Prettier with the necessary plugins and settings.
prettier-plugin-tailwindcssand add it to the Prettier configuration.Implement a
cnfunction usingclsxandtailwindMergefor managing Tailwind classnames cleanly.clsxandtailwind-mergeto the project dependencies.cnthat combines and merges classnames usingclsxandtailwind-merge.Update environment setup documentation to include instructions for setting up the Prettier configuration and git hooks.
EnvironmentSetup.mdfile.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.