Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1) install package:
- // $ npm i -D branch-name-lint
- // 2) create file branchNameLint.js
- // eslint-disable-next-line @typescript-eslint/no-var-requires
- const branchNameLint = require('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: [],
- 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);
- }
- // 3) add package.json hook
- "husky": {
- "hooks": {
- "pre-push": "node branchNameLint"
- }
- }
Add Comment
Please, Sign In to add comment