Commitlint: False positives when using the slash symbol ("/") in scope

Created on 1 Feb 2018  ยท  5Comments  ยท  Source: conventional-changelog/commitlint

If you include the slash symbol (/) in the scope of a commit message, subject-empty and type-empty rules start throwing errors.

Current Behavior

For the commit message feat(components/Component): subject, I am currently getting the following output:

> commitlint -e

โง—   input: feat(components/Component): subject
โœ–   message may not be empty [subject-empty]
โœ–   type may not be empty [type-empty]
โœ–   found 2 problems, 0 warnings

Expected Behavior

The commit message feat(components/Component): subject should pass.

Affected packages

Not sure.

Possible Solution

Not sure.

Steps to Reproduce (for bugs)

  1. Stage any changes.
  2. Commit the changes with the message that has a slash in the scope โ€“ e.g. feat(components/Component): subject
  3. Run commitlint -e


commitlint.config.js

module.exports = {
  extends: ['@anvilabs/commitlint-config'],
};

Context

Can't use scopes with slashes in them.

Your Environment

| Executable | Version |
| ---: | :--- |
| commitlint --version | 6.0.2 |
| git --version | 2.16.1 |
| node --version | 9.4.0 |

bug

Most helpful comment

@marionebl It's happening again and it's different. Example repo is here.

Looks like there's an extra new-line before my commit message:

โžœ  cra-rewired-starter git:(master) โœ— gc -m "feat(store/modules): add runtime"
husky > npm run -s precommit (node v8.11.1)

 โœ” Running tasks for {src,config}/**/*.{js,jsx,json}
 โ†“ Running tasks for src/**/*.{css,less} [skipped]
   โ†’ No staged files match src/**/*.{css,less}
husky > npm run -s commitmsg (node v8.11.1)

โง—   input:
feat(store/modules): add runtime

โœ–   message may not be empty [subject-empty]
โœ–   type may not be empty [type-empty]
โœ–   scope may not be empty [scope-empty]
โœ–   found 3 problems, 0 warnings

without slash:

โžœ  cra-rewired-starter git:(master) โœ— gc -m "feat(store-modules): add runtime"
husky > npm run -s precommit (node v8.11.1)

 โœ” Running tasks for {src,config}/**/*.{js,jsx,json}
 โ†“ Running tasks for src/**/*.{css,less} [skipped]
   โ†’ No staged files match src/**/*.{css,less}
husky > npm run -s commitmsg (node v8.11.1)

โง—   input: feat(store-modules): add runtime
โœ”   found 0 problems, 0 warnings

version:

โžœ  cra-rewired-starter git:(master) โœ— node -v
v8.11.1
โžœ  cra-rewired-starter git:(master) npm -v
6.0.0
โžœ cra-rewired-starter git:(master) โœ— grep 'version' node_modules/@commitlint/cli/package.json
    "type": "version",
  "version": "6.2.0",

cli-test:

โžœ  cra-rewired-starter git:(master) โœ— echo "feat(components, component): subject" | ./node_modules/.bin/commitlint
โง—   input: feat(components, component): subject
โœ”   found 0 problems, 0 warnings

โžœ  cra-rewired-starter git:(master) โœ— echo "feat(components/component): subject" | ./node_modules/.bin/commitlint
โง—   input: feat(components/component): subject
โœ”   found 0 problems, 0 warnings

All 5 comments

Probably a bug with conventional-commits-parser, will investigate.

Having the same issue with commas in scopes with recent releases. Works in v5.2.3, breaks in v5.2.4.

Fixed via 6.1.0. Let me know if you still run into problems!

ฮป commitlint -v
6.1.0

ฮป echo "feat(components/component): subject" | commitlint
โง—   input: feat(components/component): subject
โœ”   found 0 problems, 0 warnings

ฮป echo "feat(components, component): subject" | commitlint
โง—   input: feat(components, component): subject
โœ”   found 0 problems, 0 warnings

@marionebl It's happening again and it's different. Example repo is here.

Looks like there's an extra new-line before my commit message:

โžœ  cra-rewired-starter git:(master) โœ— gc -m "feat(store/modules): add runtime"
husky > npm run -s precommit (node v8.11.1)

 โœ” Running tasks for {src,config}/**/*.{js,jsx,json}
 โ†“ Running tasks for src/**/*.{css,less} [skipped]
   โ†’ No staged files match src/**/*.{css,less}
husky > npm run -s commitmsg (node v8.11.1)

โง—   input:
feat(store/modules): add runtime

โœ–   message may not be empty [subject-empty]
โœ–   type may not be empty [type-empty]
โœ–   scope may not be empty [scope-empty]
โœ–   found 3 problems, 0 warnings

without slash:

โžœ  cra-rewired-starter git:(master) โœ— gc -m "feat(store-modules): add runtime"
husky > npm run -s precommit (node v8.11.1)

 โœ” Running tasks for {src,config}/**/*.{js,jsx,json}
 โ†“ Running tasks for src/**/*.{css,less} [skipped]
   โ†’ No staged files match src/**/*.{css,less}
husky > npm run -s commitmsg (node v8.11.1)

โง—   input: feat(store-modules): add runtime
โœ”   found 0 problems, 0 warnings

version:

โžœ  cra-rewired-starter git:(master) โœ— node -v
v8.11.1
โžœ  cra-rewired-starter git:(master) npm -v
6.0.0
โžœ cra-rewired-starter git:(master) โœ— grep 'version' node_modules/@commitlint/cli/package.json
    "type": "version",
  "version": "6.2.0",

cli-test:

โžœ  cra-rewired-starter git:(master) โœ— echo "feat(components, component): subject" | ./node_modules/.bin/commitlint
โง—   input: feat(components, component): subject
โœ”   found 0 problems, 0 warnings

โžœ  cra-rewired-starter git:(master) โœ— echo "feat(components/component): subject" | ./node_modules/.bin/commitlint
โง—   input: feat(components/component): subject
โœ”   found 0 problems, 0 warnings

@marionebl Did you see this? Do I need to submit a new issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gajus picture gajus  ยท  4Comments

xmlking picture xmlking  ยท  4Comments

MathiasKandelborg picture MathiasKandelborg  ยท  3Comments

n0nick picture n0nick  ยท  5Comments

pixelass picture pixelass  ยท  3Comments