ESLint Rules
Last updated
Was this helpful?
Last updated
Was this helpful?
Project Zero uses a set of ESLint rules which extends upon the "eslint:recommended" rule set. These rules are marked by a checkmark at . Keep in mind that ESLint might change these at any time. You can see the extended rules in /templates/.eslintrc.js
.
Most of these added rules are from , and sections. The main goal here is to have a base set of rules that prevents some common issues and improve code readability without restricting the developer too much.
Since we use '@babel/eslint-parser' as parser, you should make sure that you're using Node.js version 14+.
To make sure ESLint is properly configured in the project and its rules are applied correctly, there is a "pre-commit" git hook. With it, no code that doesn't pass linting will be pushed to production. Of course, it is possible for developers to use "eslint-disable" statements and these should be caught and questioned during code review.
To help find and fix possible linting errors on project basis, there are 2 npm scripts: npm run lint
and npm run lint:fix
.
If you're using Visual Studio Code, following setup is recommended:
1 - Plugin:
2 - Settings: