Linting and Formatting

The project uses eslint with the Prettier plugin. eslint handles linting, but eslint rules related to code formatting, they get handled by prettier. For the most part, out of the box rules provided by the configurations that are extended are used but there are some tweaks.

Forem also has some objects that live in the global scope, e.g. Pusher. The eslint globals section of the eslint configuration is what enables these to be reported as existing when eslint runs.

globals: {
  InstantClick: false,
  filterXSS: false,
  Pusher: false,

Husky and lint-staged

The code base uses a pre-commit hook that is enabled by the husky and lint-staged tools. The pre-commit hook runs eslint before frontend code is committed. If there are any issues that can automatically be fixed, eslint will fix them. If there are linting issues that cannot be resolved, the commit fails and the changes need to be handled manually. Prettier also runs during the pre-commit hook.