question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using a type that has a dash ("-") [bug]

See original GitHub issue

Expected Behavior

commitlint should accept types with dashes in them.

Current Behavior

It gives the errors “subject may not be empty” and “type may not be empty”, neither of which is true.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Steps to Reproduce (for bugs)

echo "vim-patch: the type is not empty" | npx commitlint --config commitlint.config.js

returns

⧗   input: vim-patch: the type is not empty
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint 
commitlint.config.js module.exports = { rules: { 'body-leading-blank': [1, 'always'], 'body-max-line-length': [2, 'always', 100], 'footer-leading-blank': [1, 'always'], 'footer-max-line-length': [2, 'always', 100], 'header-max-length': [2, 'always', 100], 'scope-case': [2, 'always', 'lower-case'], 'subject-case': [ 2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], ], 'subject-empty': [2, 'never'], 'subject-full-stop': [2, 'never', '.'], 'type-case': [2, 'always', 'lower-case'], 'type-empty': [2, 'never'], 'type-enum': [ 2, 'always', [ 'build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch', ], ], }, };

Context

I contribute to the neovim project. We would like to introduce a type called vim-patch since many of our automation scripts depend on the commits having exactly that string.

Your Environment

Executable Version
commitlint --version @commitlint/cli@13.1.0, @commitlint/cli@7.6.1
git --version 2.32.0
node --version v16.5.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
AdeAttwoodcommented, Jul 28, 2021

@dundargoc happy to hear that Neovim is using commitlint in their CI. Not so happy to here you are having issues. The issue is that the header fails to parse, we are looking for any word at the start of the commit. You can override this to look for anything that is not a (, ) or : in the parserOpts.headerPattern. An example config is below, hope this fixes the issue for you.

commitlint.config.js
module.exports = {
  parserPreset: {
    parserOpts: { headerPattern: /^([^\(\):]*)(?:\((.*)\))?!?: (.*)$/ }
  },
  rules: {
    "body-leading-blank": [1, "always"],
    "body-max-line-length": [2, "always", 100],
    "footer-leading-blank": [1, "always"],
    "footer-max-line-length": [2, "always", 100],
    "header-max-length": [2, "always", 100],
    "scope-case": [2, "always", "lower-case"],
    "subject-case": [
      2,
      "never",
      ["sentence-case", "start-case", "pascal-case", "upper-case"]
    ],
    "subject-empty": [2, "never"],
    "subject-full-stop": [2, "never", "."],
    "type-case": [2, "always", "lower-case"],
    "type-empty": [2, "never"],
    "type-enum": [
      2,
      "always",
      [
        "build",
        "chore",
        "ci",
        "docs",
        "feat",
        "fix",
        "perf",
        "refactor",
        "revert",
        "test",
        "vim-patch"
      ]
    ]
  }
};

There are a few other issues around the same thing that we are looking to fix. This will take a bit of time to get the fix in, tested and released, so you can use the above config in the short term.

Ref: #2674, #880, #1221

1reaction
AdeAttwoodcommented, Jul 28, 2021

Yea please 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting App Deployment Errors - Dash Python
This troubleshooting guide describes errors that you may encounter when deploying apps to Dash Enterprise as well as steps to resolve them.
Read more >
python - Dash suppress_callback_exceptions not working
I have tried each way individually and using all of them as uncommented lines of code. No matter the combination of methods I...
Read more >
BUG in Azure Data Factory -> Set Variable -> Add dynamic ...
Hi,. I am attempting to set a variable by referring to an element inside a json array. The array element has dashes (-)...
Read more >
Syntax Error - an overview | ScienceDirect Topics
If this type of error is typed in a script or function using the Editor, ... There are many possible syntax errors—you will...
Read more >
MSE Dash MP4 video playback throw decoding error at very ...
This bug has been stale for more than a year. I've added the label StaleMediaBug and in two weeks will archive all such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found