Skip to content

Linting

John Darragh edited this page Feb 6, 2021 · 1 revision

The code base is set up to enforce fairly rigid coding conventions through a combination of Prettier for code formatting and ESLint for static code analysis.

The formatting and linting of /server and /client modules are confgured independently of each other, allowing us to enforce and evolve module-appropriate rules. The package.json files in each module's folder contain both lint and lint:fix scripts which can be run manually when you want to check for and fix, respectively, formatting and linting errors by running

npm run lint

or

npm run lint:fix

commands from the appropriate directory. As noted in the Monorepo Organization article, the lint scripts will be run in both directories by a git pre-commit hook when you attempt to commit a change to your local git repo, to make sure any code you commit is compliant with these rules. This level of enforcement not only makes the code base more consistent, professional and easier to read, but also make pull requests easier to understand, since code changes are actual changes to code logic and are not masked by tons of spurious minor differences in formatting.

The code formatting and linting rules are configured by careful selection of the appropriate NPM modules. VSCode (and other editors like Intelli-J) should automatically detect and highlight code formatting and linting violations directly in the code editor, and automatically correct correctable errors when a file is saved. When VSCode detects a formatting or linting error, it should highlight the error with a squiggle underline and

Clone this wiki locally