{"id":28480265,"url":"https://github.com/b12k/branch-name-lint","last_synced_at":"2025-07-03T18:30:34.735Z","repository":{"id":42534020,"uuid":"446779294","full_name":"b12k/branch-name-lint","owner":"b12k","description":"Flexible git branch name linter with some extra validating features","archived":false,"fork":false,"pushed_at":"2025-04-16T23:20:50.000Z","size":316,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T19:06:00.181Z","etag":null,"topics":["branch","branch-name-lint","branch-name-validation","branch-names","branch-protection","conventiona-branch-names","git-branch","git-hooks","lint","linter","validate","validate-branch-name","validation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b12k.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2022-01-11T10:43:16.000Z","updated_at":"2025-04-16T17:41:00.000Z","dependencies_parsed_at":"2025-04-16T17:35:39.970Z","dependency_job_id":"068273fc-01ac-473d-9c3a-11f9a7801cc1","html_url":"https://github.com/b12k/branch-name-lint","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/b12k/branch-name-lint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b12k%2Fbranch-name-lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b12k%2Fbranch-name-lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b12k%2Fbranch-name-lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b12k%2Fbranch-name-lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b12k","download_url":"https://codeload.github.com/b12k/branch-name-lint/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b12k%2Fbranch-name-lint/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263378903,"owners_count":23457774,"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":["branch","branch-name-lint","branch-name-validation","branch-names","branch-protection","conventiona-branch-names","git-branch","git-hooks","lint","linter","validate","validate-branch-name","validation"],"created_at":"2025-06-07T19:06:01.125Z","updated_at":"2025-07-03T18:30:34.712Z","avatar_url":"https://github.com/b12k.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable --\u003e\n\n# **\u003cdiv align=\"center\"\u003eBranch Name Lint\u003c/div\u003e**\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://bit.ly/branch-name-lint\" alt=\"BranchNameLint\"\u003e\n  \u003cp\u003eFlexible git branch naming convention checker with some extra validating features\u003c/p\u003e\n  \u003ca href=\"https://codeclimate.com/github/b12k/branch-name-lint/maintainability\"\u003e\n    \u003cimg src=\"https://api.codeclimate.com/v1/badges/90a30843ffa0d0410003/maintainability\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\n## Usage\n\n### Globally\n\n```shell\n\u003e npm install @b12k/branch-name-lint -g\n\u003e branch-name-lint\n```\n\n### As development dependency\n\n```shell\n\u003e npm install @b12k/branch-name-lint -D\n\u003e npm set-script lint:branch-name \"branch-name-lint\"\n```\n\n### With custom branch names\n\n```shell\n\u003e branch-name-lint --name=my-custom/branch-name\n```\n\n### Git hook\n\nUsing [simple-git-hooks](https://www.npmjs.com/package/simple-git-hooks)\n\n`package.json`\n\n```json\n{\n  \"simple-git-hooks\": {\n    \"pre-push\": \"branch-name-lint\"\n  }\n}\n```\n\nAlternatevly you can use it with [husky](https://www.npmjs.com/package/husky).\n\n## Configuration\n\n### Config schema\n\n```typescript\ninterface Config {\n  pattern: string;\n  params: Record\u003cstring, string[]\u003e;\n  prohibited: string[];\n}\n```\n\n### User provided configuration\n\nUnder the hood **BranchNameLint** uses [cosmicconfig](https://www.npmjs.com/package/cosmiconfig)\nto load its configuration.\n\nYou can create one of the following:\n\n- `branchnamelint` property in the `package.json` file\n- Extensionless \"rc file\" in `.json` or `.yaml` format\n  - `.branchnamelintrc`\n- \"rc file\" with `.json` or `.yaml` extensions\n  - `.branchnamelintrc.json`\n  - `.branchnamelintrc.yaml`\n- \"rc file\" with `.js` extension\n  - `.branchnamelintrc.js`\n- \".config.js\" file\n  - `branchnamelint.config.js`\n\n\u003e don't forget to do `module.exports = {...}` in `.js` config files\n\n**BranchNameLint** will merge found configuration with its defaults.\n\n### Default configuration\n\n```javascript\nmodule.exports = {\n  pattern: ':type/:name',\n  params: {\n    type: [\n      'fix',\n      'docs',\n      'misc',\n      'improve',\n      'introduce',\n    ],\n    name: ['[a-z0-9-]+'],\n  },\n  prohibited: [\n    'ci',\n    'wip',\n    'main',\n    'test',\n    'build',\n    'master',\n    'release',\n  ],\n};\n```\n\n### Linting\n\n**BranchNameLint** uses [path-to-regexp](https://www.npmjs.com/package/path-to-regexp)\nto check if branch name matches the `pattern` provided in config.\n\nFirstly branch name will be checked if its `prohibited` or not. On the next step,\nif `params` are provided, `pattern` parts will be modified/populated using\nrespective keys. For example:\n\n```text\n(default configuration)\n:type/:name =\u003e :type(feature|fix|misc|docs)/:name([a-z0-9-]+)\n```\n\nPlease refer to [path-to-regexp](https://www.npmjs.com/package/path-to-regexp)\ndocs for advanced patterns.\n\n## Configuration recipes\n\n### Only check for protected branches\n\n```typescript\nmodule.exports = {\n  pattern: '', // or other falsy value: undefined | 0 | null | false\n  params: {},\n  prohibited: [\n    'master',\n    'main',\n    'build',\n    'test',\n    'wip',\n    'ci',\n    'release',\n  ],\n};\n```\n\n### Dot-separated username \u0026 issue id\n\n`b12k.fix/example-branch-description/lbn-12345`\n\n```typescript\nmodule.exports = {\n  pattern: ':username.:type/:desc/:issue',\n  params: {\n    type: [\n      'feature',\n      'fix',\n      'misc',\n      'docs',\n    ],\n    issue: ['lbn-[a-z0-9-]+'],\n  },\n  prohibited: [\n    'master',\n    'main',\n    'build',\n    'test',\n    'wip',\n    'ci',\n    'release',\n  ],\n};\n```\n\n### Scopes for monorepo\n\n`feature/my-awesome-app/yet-another-great-feature`\n\n```text\n(imaginary monorepo structure)\nroot/\n    apps/\n        my-awesome-app\n        another-great-app\n    libs/\n        very-useful-lib\n        shared-lib\n    .branchnamelintrc.js\n```\n\n```typescript\nconst fs = require('fs');\n\nconst readDirectories = (path) =\u003e fs\n  .readdirSync(path, { withFileTypes: true })\n  .filter((file) =\u003e file.isDirectory())\n  .map(({ name }) =\u003e name);\n\nmodule.exports = {\n  pattern: ':type/:scope/:description',\n  params: {\n    type: [\n      'feature',\n      'fix',\n      'misc',\n      'docs',\n    ],\n    scope: readDirectories('./apps')\n  },\n  prohibited: [\n    'master',\n    'main',\n    'build',\n    'test',\n    'wip',\n    'ci',\n    'release',\n  ],\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb12k%2Fbranch-name-lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb12k%2Fbranch-name-lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb12k%2Fbranch-name-lint/lists"}