Learn
M6: Tooling

Module 6: Tooling

Green Boost (GB) tooling includes: PNPM, ESLint, TypeScript Compiler, NPM Audit, Prettier, and Husky. GB projects created with gboost create are setup as a monorepo.

Learn

Apply

M6.1 - PNPM Workspaces

  • Review the pnpm-workspace.yaml file in root of GB repo. Understand how workspaces reference each other’s packages

M6.2 - PNPM Scripts

  • Run pnpm lint and pnpm typecheck and pnpm test in the root of the repository. Notice how PNPM is running those commands in every workspace that has those commands within their package.json#scripts

M6.3 - Static Code Analysis with ESLint

  • Intentionally create a code-smell (see all rules here (opens in a new tab)) and verify ESLint is runs and shows red squiggles in your editor. If you're using VS Code, you will need to install the ES Lint Extension to see linting. Also recommend the Error Lens extension if you like seeing the error in line with your code.
  • Review ESLint configuration. Add a custom ESLint rule. Understand how ESLint works with Prettier to enforce code formatting.

M6.4 - NPM Audit

  • pnpm audit is an alias for npm audit
  • Run pnpm audit. Any CVEs?
  • If you found any CVEs of sub-dependencies - dependencies that you didn't specify the version for. How can you update them? Checkout PNPM's overrides configuration option. Now override the offending package's version with the overrides configuration option and verify pnpm audit succeeds.

M6.5 - Pre-commit Hooks

  • Make an update in a TypeScript file in each each top level folder. The change can be as trivial as adding a comment.
  • Now stage and commit those changes.
  • Notice how Husky's pre-commit hook defined in .husky/pre-commit runs invoking pnpm lint-staged which in turn runs the .lintstagedrc.js file in each top level folder.