<aside> ☝ This is a simple guide that shows how to set up linting and testing frameworks, and offers a reccomendation of which linters and style guides to use.
</aside>
Code quality composes of a number of aspects, including effective code reviews and good variable naming. Here, we will walk through how to set up linting and testing frameworks, which are simple methods that ensure code style and consistency, as well as functionality. Once this is done, you’ll never have to touch it again.
Linting is simply the process of enforcing a specific code style standard. this one is super easy because it will never change code logic (if you lint bad code, it will be bad code, but pretty). so all you have to do is run it and not worry that it will break anything.
Use ESLint as the linter, and Prettier and Airbnb React/JavaScript style guide as the standards. These are super customizable, and offer a lot of flexibility. Again, look at YMCA client linting.
TODO: More in depth walkthrough
Type checking is also very valuable, and offers the benefit of cutting down bugs. However, this is extremely hard to enforce, especially in fast moving teams like ours. Its still a good metric though.
Black is sexy
Once you set up the linting workflows, there should be a simple command to ensure that the project is linting (such as yarn lint
). You can add this as a workflow to your CI.
You can also add a pre-commit hook. this is super unnecessary but will definitely save spam 'fix lint’ commit messages.
TODO: More in depth walkthrough
Testing is a crucial part of project development for our teams. However, tests tend to be added later in the project timeline, as feature development takes priority. Even so, it is good to set up testing infrastructure from the beginning, so you don't have to deal with it later. Even if there aren't any tests being run.