Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint changed files by default in pre-push hook #4261

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on May 7, 2024

  1. Lint changed files by default in pre-push hook

    Currently if you install the pre-push hook by running `yarn
    setup-git-hooks`, then each time you push, every file that can be linted
    will be. This is incredibly time-consuming if you want to push a branch
    and you've only changed a handful of files on your branch.
    
    To address this, this commit adds a shell script which replaces the
    existing `lint` and `lint:fix` package scripts. This new script not only
    runs in "check" and "fix" modes (that is, either check and exit without
    fixes, or check and automatically make fixes), it also has the ability
    to detect which files have changed within the branch that you're on and
    only run ESLint and Prettier on those files.
    
    To accomplish this, the argument to `eslint` and `prettier` have been
    simplified so that instead of excluding non-lintable files when these
    commands are called, ignore files are used instead. This required
    updating to Prettier 3, which reads from both `.prettierignore` and
    `.gitignore`, a useful task Prettier 2 did not do.
    
    Of course, you don't need to install the Git hook to take advantage of
    the changes in this commit. The `lint` and `lint:fix` package scripts
    now take advantage of the new shell script, and there are also two new
    package scripts that delegate to the script, namely, `lint:only-branch`
    and `lint:fix:only-branch`.
    
    Finally, CI will still run `yarn lint` to ensure that all files in the
    repo still pass lint.
    mcmire committed May 7, 2024
    Configuration menu
    Copy the full SHA
    806c2ff View commit details
    Browse the repository at this point in the history