Tests are essential
- To ensure you have them, measure code coverage, for example
- Test quality itself takes effort to maintain over time in order for tests to continue to add value
Linting is essential
- Don't argue over syntax in Code Reviews, use tools such as ESlint with a robust configuration to prevent many potential bugs. Robust configuration means use a LOT of rules to help you write quality code. See below for list.
Grading is important
- Use a tool that measures and grades your code, e.g. js-grader Make sure grades don't drop
Standardized formatting is helpful
- Use prettier or beautifier to standardize layout, improve readability and reduce variability
- Agree on standards through tool configuration over constant code review syntax discussions
Automation of the above is essential!
The steps above MUST be incorporated into the development process as automatic procedures that make developers lives easier, not more burdensome. For example, run linting and grading before tests, run tests automatically in the cloud in CI for all code commit pushes to remote before merging them into master, run tests in master before deploying to another environment, etc. Automate code grading and consider a downgrade to be a failed test. Make quality easy and instill pride in your developers.
eslint.config file that I am using:
package.json file that I am using.
Note how scripts run linting, tests and code coverage every time.
npm run coverage
to trigger all three scripts.
"pretest": "eslint .",
"test": "mocha **/*.spec.* --exclude node_modules/**/*.spec.js",
"coverage": "nyc npm run test"
Note the use of eslint-plugin-mocha, otherwise all the
its are unrecognized.