Git Hooks — Guardian Angel

Git Pre-commit Hook

#!/bin/bashecho "---------------------------------------------"echo "executing precommit hook for running linters"echo "---------------------------------------------"#let run the hook on stages files not on all filesfor file in $(git diff --cached --name-only | grep -E '\.(js|ts|vue)$')doecho "file :$file -  being scanned for lint issue"git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file"# we only want to lint the staged changes, not any un-staged changesif [ $? -ne 0 ]; thenecho "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."exit 1 # exit with failure statusfidone

--

--

--

Front End Engineer | Netherlands. They say being human means having doubts yet still continuing on your path, so as I am. www.santhoshkumar.tech

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to add push notifications to a progressive web app

Build, run and deploy Vuejs app with Quarkus

Objects and it’s internal representation in JavaScript.

2 Simple Tricks to Lower Your JS Torture

Now Experience UI Framework: custom components

Basic 3D rendering in SVG: elm-playground-3d

Overcoming browser throttling of setInterval executions

MEAN(Y) Stack Tutorial

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Santhoshkumar Ravi

Santhoshkumar Ravi

Front End Engineer | Netherlands. They say being human means having doubts yet still continuing on your path, so as I am. www.santhoshkumar.tech

More from Medium

[cvs-plugin] VSCode extension to help you get over CVS.

File Structure & Organized Code

REST services & Koa.JS