0

I am newly(ish) responsible for a git repository. When I clone it and look in the .git/hooks directory, there are only sample hooks.

We use NPM as our package manager for the front end UI. After I run an "npm install", I 'all of a sudden' have real git hooks in .git/hooks. How does this work? What am I looking for?

I figure it is some kind of hook, but I am not sure where to start looking to track it down. In my package.json file I see tslint-react-hooks (TSLint rule that enforces the Rules of Hooks) and react-hook-form (Performant, flexible and extensible forms with easy-to-use validation.), but I think these are red herrings.

I've seen this question Putting Git hooks into a repository which talks about getting hooks in place, but I don't see how it happens for this project.

Here is a copy of my package.json file. Thanks for any insights.

{
"name": "ram",
"version": "1.0.0",
"description": "RAM UI Build Tools",
"scripts": {
    "test": "jest --coverage --watchAll",
    "testOnce": "jest",
    "build": "cross-env NODE_ENV=production node ./Config/prod.js",
    "build:dev": "cross-env NODE_ENV=development node ./Config/dev-noserver.js",
    "dev": "cross-env NODE_ENV=development nodemon -e js,ts,tsx,json,scss ./Config/dev-noserver.js",
    "start": "cross-env NODE_ENV=development node ./Config/dev.js",
    "start:full": "webpack-dev-server --progress --config ./Config/dev-noserver-hot.js",
    "precommit": "lint-staged"
},
"lint-staged": {
    "*.{js,ts,tsx,json,scss}": [
        "prettier --write",
        "git add"
    ],
    "*.scss": [
        "stylelint --fix",
        "git add"
    ],
    "*.{ts,tsx}": [
        "tslint --fix",
        "git add"
    ]
},
"prettier": {
    "singleQuote": true,
    "tabWidth": 4,
    "printWidth": 120
},
"jest": {
    "moduleFileExtensions": [
        "ts",
        "tsx",
        "js"
    ],
    "transform": {
        "^.+\\.tsx?$": "ts-jest"
    },
    "testMatch": [
        "**/?(*.)(spec|test).ts?(x)"
    ],
    "modulePaths": [
        "<rootDir>/Content"
    ],
    "testPathIgnorePatterns": [
        "/node_modules",
        "./Config"
    ],
    "collectCoverage": true,
    "collectCoverageFrom": [
        "**/*.*",
        "!**/*.json",
        "!**/index.ts"
    ],
    "coveragePathIgnorePatterns": [
        "/node_modules/",
        "./Config",
        "./coverage",
        "./Types",
        "__snapshots__",
        "__tests__",
        "index.tsx",
        "./Content/Pages",
        "./Content/Utils/constants.ts"
    ],
    "coverageReporters": [
        "html"
    ],
    "setupFilesAfterEnv": [
        "./Config/Test/testFramework.js"
    ],
    "testURL": "http://localhost/"
},
"author": "xxxxxxxxxxxxx",
"license": "UNLICENSED",
"private": true,
"devDependencies": {
    "@types/classnames": "2.2.3",
    "@types/enzyme": "3.1.10",
    "@types/history": "4.6.2",
    "@types/jest": "22.2.3",
    "@types/jquery": "3.3.1",
    "@types/lodash": "4.14.110",
    "@types/object-hash": "1.2.0",
    "@types/query-string": "6.2.0",
    "@types/react-beautiful-dnd": "12.1.2",
    "@types/react-bootstrap": "0.32.21",
    "@types/react-datepicker": "2.9.5",
    "@types/react-dom": "18.0.0",
    "@types/react-js-pagination": "3.0.3",
    "@types/react-router": "4.0.23",
    "@types/react-router-dom": "4.2.6",
    "@types/react-test-renderer": "16.0.1",
    "@types/react-toggle": "4.0.2",
    "@types/styled-components": "5.1.25",
    "@types/uuid": "3.4.3",
    "@types/webpack-env": "1.13.6",
    "@typescript-eslint/eslint-plugin": "5.35.1",
    "@typescript-eslint/parser": "5.35.1",
    "axios-mock-adapter": "1.15.0",
    "cross-env": "5.1.4",
    "css-hot-loader": "1.3.9",
    "css-loader": "0.28.11",
    "ejs-loader": "0.3.1",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.1.1",
    "eslint": "8.22.0",
    "eslint-config-standard-with-typescript": "22.0.0",
    "eslint-plugin-import": "2.26.0",
    "eslint-plugin-n": "15.2.5",
    "eslint-plugin-promise": "6.0.1",
    "eslint-plugin-react": "7.31.0",
    "html-webpack-plugin": "3.2.0",
    "husky": "0.14.3",
    "jest": "26.4.2",
    "lint-staged": "13.0.3",
    "mini-css-extract-plugin": "0.4.0",
    "node-sass": "4.14.0",
    "nodemon": "1.17.3",
    "postcss-flexbugs-fixes": "3.3.0",
    "postcss-loader": "2.1.4",
    "prettier": "1.19.1",
    "react-test-renderer": "18.2.0",
    "sass-loader": "7.0.1",
    "style-loader": "0.20.3",
    "stylelint": "9.2.0",
    "stylelint-config-recommended-scss": "3.2.0",
    "stylelint-declaration-strict-value": "1.0.4",
    "stylelint-declaration-use-variable": "1.6.1",
    "stylelint-formatter-pretty": "1.0.3",
    "stylelint-scss": "3.0.0",
    "stylelint-webpack-plugin": "0.10.4",
    "ts-jest": "26.3.0",
    "ts-loader": "8.0.3",
    "ts-react": "1.2.1",
    "tsconfig-paths-webpack-plugin": "3.0.4",
    "tslint": "6.1.3",
    "tslint-config-prettier": "1.18.0",
    "tslint-loader": "3.5.4",
    "tslint-react": "5.0.0",
    "tslint-react-hooks": "2.2.2",
    "typescript": "4.6.4",
    "webpack": "4.46.0",
    "webpack-cli": "2.0.14",
    "webpack-dev-server": "3.10.3",
    "xml2js": "0.4.19"
},
"dependencies": {
    "@hapi/cryptiles": "*",
    "@types/react-table": "6.7.12",
    "axios": "0.27.2",
    "babel-loader": "8.2.5",
    "bootstrap": "3.3.5",
    "chokidar": "3.5.3",
    "classnames": "2.2.5",
    "core-js": "3.24.1",
    "ejs": "3.1.8",
    "eslint-config-airbnb": "19.0.4",
    "eslint-config-airbnb-base": "15.0.0",
    "eslint-config-react-app": "7.0.1",
    "eslint-plugin-jsx-a11y": "6.6.1",
    "eslint-utils": "3.0.0",
    "eventsource": "2.0.2",
    "expose-loader": "0.7.5",
    "file-loader": "1.1.11",
    "font-awesome": "4.7.0",
    "highcharts": "10.1.0",
    "highcharts-react-official": "3.0.0",
    "history": "4.7.2",
    "jquery": "2.1.1",
    "json-schema": "0.4.0",
    "lodash": "4.17.21",
    "object-hash": "1.3.1",
    "popper": "1.0.1",
    "powerbi-client": "2.18.6",
    "powerbi-client-react": "1.3.3",
    "prop-types": "15.6.1",
    "querystring": "0.2.0",
    "react": "18.2.0",
    "react-beautiful-dnd": "13.0.0",
    "react-bootstrap": "0.33.1",
    "react-datepicker": "4.8.0",
    "react-dev-utils": "12.0.1",
    "react-dom": "18.2.0",
    "react-filtered-multiselect": "0.5.1",
    "react-hook-form": "6.5.3",
    "react-input-switch": "2.2.2",
    "react-js-pagination": "3.0.3",
    "react-promise": "2.0.3",
    "react-query": "3.39.0",
    "react-router-dom": "4.2.2",
    "react-socks": "2.2.0",
    "react-string-replace": "0.4.1",
    "react-super-select": "1.0.23",
    "react-table": "6.8.6",
    "react-table-hoc-fixed-columns": "1.0.0-beta.9",
    "react-toastify": "5.5.0",
    "react-toggle": "4.1.3",
    "shell-quote": "1.7.3",
    "string-replace-to-array": "1.0.3",
    "styled-components": "5.3.5",
    "sweetalert": "2.1.2",
    "sync-request": "6.0.0",
    "tar": "6.1.11",
    "ts-node": "10.9.1",
    "ts-node-dev": "2.0.0",
    "uglify-js": "3.15.5",
    "url-parse": "1.5.10",
    "uuid": "8.3.2",
    "webpack-dev-middleware": "5.3.3"
}

}

Joe Derham
  • 37
  • 1
  • 7

1 Answers1

0

Installing devDependency "husky": "0.14.3" is the culprit.

Joe Derham
  • 37
  • 1
  • 7
  • Well, that package is specifically for creating git hooks. If you don't want them, remove the dependency ... – derpirscher Aug 28 '22 at 11:34
  • I was wondering how it was working. There is a lot that I don't understand of this infrastructure. Slowly, painfully, but surely. – Joe Derham Aug 29 '22 at 13:44