Skip to content

Instantly share code, notes, and snippets.

@crutch12
Created April 16, 2022 23:45
Show Gist options
  • Save crutch12/5430853b09aca4d305b8e4b6cfd6b4e4 to your computer and use it in GitHub Desktop.
Save crutch12/5430853b09aca4d305b8e4b6cfd6b4e4 to your computer and use it in GitHub Desktop.
Branch name lint config (+ .husky/pre-push hook file)
// eslint-disable-next-line @typescript-eslint/no-var-requires
const branchNameLint = require('@web-bee-ru/branch-name-lint');
// See: https://github.com/barzik/branch-name-lint#options
const options = {
prefixes: ['feature', 'hotfix', 'release'],
suggestions: {
features: 'feature',
feat: 'feature',
fix: 'hotfix',
releases: 'release',
},
banned: ['wip', 'bugfix'],
skip: ['master', 'develop', 'main'],
disallowed: ['staging'],
separator: '/',
msgBranchBanned: 'Branches with the name "%s" are not allowed.',
msgBranchDisallowed: 'Pushing to "%s" is not allowed, use git-flow.',
msgPrefixNotAllowed: 'Branch prefix "%s" is not allowed.',
msgPrefixSuggestion: 'Instead of "%s" try "%s".',
msgseparatorRequired: 'Branch "%s" must contain a separator "%s".',
msgDoesNotMatchRegex: 'Branch "%s" does not match the allowed pattern: "%s"',
};
const answer = new branchNameLint(options).doValidation();
if (answer === 1) {
process.exit(1);
}
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
node ./branchNameLint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment