This video is available to students only


Git hooks to prevent bad commits.


Lint-staged can be found at

Lint-staged is a tool that prevents bad code from leaving a developer's computer. It allows us to run commands on staged files when a developer runs git commit. If any of the commands fail then the commit also fails—preventing bad commits from being pushed to GitHub. Lint-staged is a great way of ensuring linting, testing, and other operations are performed before contributions get pushed to GitHub.

Lint-staged uses Husky and Git hooks behind the scenes.

Run npx [email protected] lint-staged at the root of Scroller. Since we need to use the [email protected] script, which is a remote script, we need npx. Enter y to proceed if the following is prompted:

This adds lint-staged and husky as a devDependency, and a .husky/ directory which can be ignored. Lint-staged also adds a "lint-staged" property into our package.json where we'll define what scripts we want to run before commits. Lint-staged defaults with "*.js": "eslint --cache --fix" which will run ESLint on changed JavaScript files; we'll update this later to lint TypeScript files and run tests.


This page is a preview of Creating React Libraries from Scratch

No discussions yet. Be the first. All notification go to the author.