Skip to content

ci: run client linters on changed files

Warren Gifford requested to merge vb/lint-changed into main

Created by: valerybugakov

Context

We lint all css and ts files on every PR, which is wasteful, especially for pull requests where a small number of files are affected. We can lint only files changed in a pull request to save some CI resources and make the feedback cycle faster.

Related Slack thread.

Changes

  • Run stylelint and eslint only on changed files in PRs. On main all files will be linted as usual.
  • Run stylelint on all .scss files in the client folder instead of explicitly listing a set of packages to check. Because we relied on the manually updated list of packages to check, some recently added client packages were ignored here.
  • Changed npm scripts format for lint commands:
    • Use _ to mark internal commands used by other npm scripts.
    • Uncouple lint commands from libraries used for linting. E.g., eslint -> lint:js. It allows using yarn prettier to call the prettier binary instead of calling our npm script, which is useful during local development.
    • Use a consistent format for lint npm commands in the client codebase – lint:lang:modifier. E.g., lint:js, lint:js:changed, lint:css:all, etc.

Time improvements

Improvements will vary depending on the PR scope, but in PRs with a few client changes, the eslint check can be up to 4x faster. Feels good 😌

Before After
Screen Shot 2022-04-12 at 13 52 42 Screen Shot 2022-04-12 at 13 52 55

Used two CI builds for comparison:

  1. This branch with a minimal number of changed .ts files.
  2. This branch dry-run that checks all .ts files.

Test plan

Verify that ESLint and Stylelint CI checks are executed only on files changed in the PR.

Merge request reports

Loading