{"id":25014,"library":"branch-name-lint","title":"branch-name-lint","description":"A CLI tool to lint and validate Git branch names against configurable rules. Current stable version is 3.0.1, requiring Node.js >=18. It supports prefix whitelisting, separator enforcement, regex patterns, banned/disallowed branch names, and suggestions for common typos. Key differentiators include support for JavaScript config files (for dynamic rules), environment variable override for CI/CD, and the ability to disable prefix or separator checks entirely. Useful for pre-commit hooks (husky) or CI pipelines to enforce branch naming conventions. Last major version (2.0.0) fixed spelling of 'separator' from 'seperator' and made branch names case-sensitive. Release cadence is irregular with maintenance updates.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/barzik/branch-name-lint","tags":["javascript","cli-app","cli","branch-name-lint","lint","validate","branch"],"install":[{"cmd":"npm install branch-name-lint","lang":"bash","label":"npm"},{"cmd":"yarn add branch-name-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add branch-name-lint","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v3.0.0; use import. For CommonJS use dynamic import() or stick to v2.x.","wrong":"const branchNameLint = require('branch-name-lint')","symbol":"default","correct":"import branchNameLint from 'branch-name-lint'"},{"note":"Default export is the lint function; named import will fail.","wrong":"import { branchNameLint } from 'branch-name-lint'","symbol":"branchNameLint","correct":"import branchNameLint from 'branch-name-lint'"},{"note":"Type imports require using `import type` in TypeScript; otherwise it will try to import runtime value.","wrong":"import { BranchNameLintConfig } from 'branch-name-lint'","symbol":"types","correct":"import type { BranchNameLintConfig } from 'branch-name-lint'"}],"quickstart":{"code":"import branchNameLint from 'branch-name-lint';\n\nconst config = {\n  prefixes: ['feature', 'hotfix', 'release'],\n  separator: '/',\n  banned: ['wip'],\n  disallowed: ['master', 'develop'],\n  suggestions: { feat: 'feature', fix: 'hotfix' },\n};\n\nconst result = branchNameLint(config, 'feature/my-branch');\n\nif (result.valid) {\n  console.log('Branch name is valid!');\n} else {\n  console.error('Invalid branch name:', result.errors);\n}","lang":"typescript","description":"Shows how to import and use branch-name-lint programmatically with a config object."},"warnings":[{"fix":"Update config to use new option names 'separator' and 'msgseparatorRequiredL'.","message":"Option names changed in v2.0.0: 'seperator' -> 'separator', 'msgseperatorRequiredL' -> 'msgseparatorRequiredL'. Old names cause silent ignore.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Ensure branch names and config prefixes match case exactly.","message":"Branch name and prefix are now case-sensitive in v2.0.0. Previously 'Feature' would match 'feature' prefix.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use import or dynamic import(). For CommonJS projects, pin to v2.1.1.","message":"ESM-only since v3.0.0. CommonJS require() will fail with ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"","message":"No deprecations known.","severity":"deprecated","affected_versions":"all"},{"fix":"Use absolute path or ensure correct relative path from cwd.","message":"Config file location as CLI argument is relative to current working directory, not the project root.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change to: import branchNameLint from 'branch-name-lint'","cause":"Using named import instead of default import.","error":"TypeError: branchNameLint is not a function"},{"fix":"Use import or upgrade Node.js to support ES modules, or use dynamic import().","cause":"Using CommonJS require() with v3.x which is ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Ensure case matches between config prefixes and branch names.","cause":"Case sensitivity change in v2.0.0; prefix in config is lowercase but branch uses uppercase.","error":"Invalid branch prefix \"Feature\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}