{"id":21089385,"url":"https://github.com/id1945/angular-husky-pre-commit","last_synced_at":"2025-07-05T15:13:11.807Z","repository":{"id":149901876,"uuid":"622427121","full_name":"id1945/angular-husky-pre-commit","owner":"id1945","description":"Clean code - Husky and Git Hook","archived":false,"fork":false,"pushed_at":"2023-04-02T05:59:50.000Z","size":536,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T00:50:23.270Z","etag":null,"topics":["angular","angular15","codelyzer","husky","lint-staged","tslint"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/id1945.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-02T04:23:18.000Z","updated_at":"2023-04-02T06:02:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"fefc99a8-e7eb-44b7-9353-945915ae04d2","html_url":"https://github.com/id1945/angular-husky-pre-commit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular-husky-pre-commit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular-husky-pre-commit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular-husky-pre-commit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular-husky-pre-commit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/id1945","download_url":"https://codeload.github.com/id1945/angular-husky-pre-commit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532564,"owners_count":20306157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular15","codelyzer","husky","lint-staged","tslint"],"created_at":"2024-11-19T21:28:40.506Z","updated_at":"2025-03-14T06:13:26.670Z","avatar_url":"https://github.com/id1945.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clean code - Husky and Git Hooks in Angular application\n\nhttps://githooks.com\nhttps://typicode.github.io/husky\n\n\u003eAssume that we are missing the sign semicolon\n[![Precommit validations using husky and lint-staged](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-1.png)](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-1.png)\n\u003egit add .\n\u003egit commit -m \"test\"\n[![Precommit validations using husky and lint-staged](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-2.png)](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-2.png)\n\u003efixed\n[![Precommit validations using husky and lint-staged](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-3.png)](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-3.png)\n\u003egit push origin master\n[![Precommit validations using husky and lint-staged](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-4.png)](https://raw.githubusercontent.com/id1945/angular-precommit/master/clean-code-4.png)\n\n# Install husky\n\n### install\n```\nnpm i husky -D\n```\n\n### enable git hook\n```\nnpx husky install\n```\n\n### add script into package.json\n```\nnpm pkg set scripts.prepare=\"husky install\"\n```\n\n\n### modify pre-commit\n```\n#!/bin/sh\n. \"$(dirname \"$0\")/_/husky.sh\"\n\nnpx lint-staged --no-stash -q -d\n```\n\n\n# Install tslint lint-staged codelyzer\n\n### install\n```\nnpm i tslint lint-staged codelyzer -D\n```\n\n### modify package.json\n```javascript\n\"lint-staged\": {\n    \"*.ts\": \"tslint -p ./tsconfig.json\"\n}\n```\n\n### add tslint.json\n```json\n{\n    \"extends\": \"tslint:recommended\",\n    \"rulesDirectory\": [\n      \"codelyzer\"\n    ],\n    \"rules\": {\n      \"align\": {\n        \"options\": [\n          \"parameters\",\n          \"statements\"\n        ]\n      },\n      \"array-type\": false,\n      \"arrow-return-shorthand\": true,\n      \"curly\": true,\n      \"deprecation\": {\n        \"severity\": \"warning\"\n      },\n      \"eofline\": true,\n      \"import-blacklist\": [\n        true,\n        \"rxjs/Rx\"\n      ],\n      \"import-spacing\": true,\n      \"indent\": {\n        \"options\": [\n          \"spaces\"\n        ]\n      },\n      \"max-classes-per-file\": false,\n      \"max-line-length\": [\n        true,\n        140\n      ],\n      \"member-ordering\": [\n        true,\n        {\n          \"order\": [\n            \"static-field\",\n            \"instance-field\",\n            \"static-method\",\n            \"instance-method\"\n          ]\n        }\n      ],\n      \"no-console\": [\n        true,\n        \"debug\",\n        \"info\",\n        \"time\",\n        \"timeEnd\",\n        \"trace\"\n      ],\n      \"no-empty\": false,\n      \"no-inferrable-types\": [\n        true,\n        \"ignore-params\"\n      ],\n      \"no-non-null-assertion\": true,\n      \"no-redundant-jsdoc\": true,\n      \"no-switch-case-fall-through\": true,\n      \"no-var-requires\": false,\n      \"object-literal-key-quotes\": [\n        true,\n        \"as-needed\"\n      ],\n      \"quotemark\": [\n        true,\n        \"single\"\n      ],\n      \"semicolon\": {\n        \"options\": [\n          \"always\"\n        ]\n      },\n      \"space-before-function-paren\": {\n        \"options\": {\n          \"anonymous\": \"never\",\n          \"asyncArrow\": \"always\",\n          \"constructor\": \"never\",\n          \"method\": \"never\",\n          \"named\": \"never\"\n        }\n      },\n      \"typedef\": [\n        true,\n        \"call-signature\"\n      ],\n      \"typedef-whitespace\": {\n        \"options\": [\n          {\n            \"call-signature\": \"nospace\",\n            \"index-signature\": \"nospace\",\n            \"parameter\": \"nospace\",\n            \"property-declaration\": \"nospace\",\n            \"variable-declaration\": \"nospace\"\n          },\n          {\n            \"call-signature\": \"onespace\",\n            \"index-signature\": \"onespace\",\n            \"parameter\": \"onespace\",\n            \"property-declaration\": \"onespace\",\n            \"variable-declaration\": \"onespace\"\n          }\n        ]\n      },\n      \"variable-name\": {\n        \"options\": [\n          \"ban-keywords\",\n          \"check-format\",\n          \"allow-pascal-case\"\n        ]\n      },\n      \"whitespace\": {\n        \"options\": [\n          \"check-branch\",\n          \"check-decl\",\n          \"check-operator\",\n          \"check-separator\",\n          \"check-type\",\n          \"check-typecast\"\n        ]\n      },\n      \"component-class-suffix\": true,\n      \"contextual-lifecycle\": true,\n      \"directive-class-suffix\": true,\n      \"no-conflicting-lifecycle\": true,\n      \"no-host-metadata-property\": true,\n      \"no-input-rename\": true,\n      \"no-inputs-metadata-property\": true,\n      \"no-output-native\": true,\n      \"no-output-on-prefix\": true,\n      \"no-output-rename\": true,\n      \"no-outputs-metadata-property\": true,\n      \"template-banana-in-box\": true,\n      \"template-no-negated-async\": true,\n      \"use-lifecycle-interface\": true,\n      \"use-pipe-transform-interface\": true,\n      \"directive-selector\": [\n        true,\n        \"attribute\",\n        \"app\",\n        \"camelCase\"\n      ],\n      \"component-selector\": [\n        true,\n        \"element\",\n        \"app\",\n        \"kebab-case\"\n      ]\n    }\n}\n```\n\n[![Precommit validations using husky and lint-staged](https://img.youtube.com/vi/yvZEAhwWVKU/maxresdefault.jpg)](http://www.youtube.com/watch?v=yvZEAhwWVKU)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fid1945%2Fangular-husky-pre-commit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fid1945%2Fangular-husky-pre-commit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fid1945%2Fangular-husky-pre-commit/lists"}