Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use parser headerPattern #607

Open
@blackswanny

Description

The task is to use commitlint to prevent commits from being commited. I use husky as well
when I test it and run
echo "bla bla bla" | npx commitlint
It doesn't catch anything and shows no errors found

⧗ input: bla bla bla 
✔ found 0 problems, 0 warnings 

Please, help, why it ignores parserOpts.headerPattern ?
Also some other notice:
I need at least one rule, otherwise commitlint doesn't want to run
Do I need to add headerCorrespondence to make it work or I can have headerPattern only?
Can I customize report message in case if I headerPattern is not matched?

commitlint.config.js

module.exports = {
 rules: {
 'header-min-length': [2, 'always', 20],
 },
 parserPreset: {
 parserOpts: {
 headerPattern: /^(feat|fix|perf|test|BREAKINGCHANGE):.*\[REF-(\d{3,}|N\\A)\]\S+\S+\S+\S+\S+/,
 headerCorrespondence: ['type', 'scope', 'subject']
 }
 }
};

husky in package.json

 "husky": {
 "hooks": {
 "pre-push": "npm test",
 "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
 }
 }

I installed the next

 "@commitlint/cli": "^7.5.2",
 "@commitlint/parse": "^7.5.0",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /