Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"trailer-exists" rule not recognized as a valid rule #3033

Closed
ND56 opened this issue Feb 16, 2022 · 1 comment
Closed

"trailer-exists" rule not recognized as a valid rule #3033

ND56 opened this issue Feb 16, 2022 · 1 comment

Comments

@ND56
Copy link

ND56 commented Feb 16, 2022

Documentation states that a trailer-exists rule is valid, but commitlint does not recognize it as a valid rule name.

Expected Behavior

Based on the documentation, I expected to be able to add this rule to my commitlint config to verify that the footer of a commit is always prefaced by something; e.g., like this:

const Configuration = {
  /*
   * Resolve and load @commitlint/config-conventional from node_modules.
   * Referenced packages must be installed
   */
  extends: ["@commitlint/config-conventional"],
  /*
   * Any rules defined here will override rules from @commitlint/config-conventional
   */
  rules: {
    "trailer-exists": [2, "always", "Jira:"],
  },
};

Current Behavior

Currently, I get this error when I attempt to commit my code and trigger that rule (stating that trailer-exists is not an accepted rule):

RangeError: Found invalid rule names: trailer-exists. Supported rule names are: body-case, body-empty, body-leading-blank, body-max-length, body-max-line-length, body-min-length, footer-empty, footer-leading-blank, footer-max-length, footer-max-line-length, footer-min-length, header-case, header-full-stop, header-max-length, header-min-length, references-empty, scope-case, scope-empty, scope-enum, scope-max-length, scope-min-length, signed-off-by, subject-case, subject-empty, subject-full-stop, subject-max-length, subject-min-length, type-case, type-empty, type-enum, type-max-length, type-min-length
    at Object.<anonymous> (/Users/ndrew/.cache/pre-commit/repo47fm2bwy/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/lint/lib/index.js:76:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

My Environment

Executable Version
commitlint --version @commitlint/cli": "^16.2.1"
git --version git version 2.32.0 (Apple Git-132)
node --version Node.js v17.5.0
@escapedcat
Copy link
Member

commitlint.config.js

module.exports = {
  /*
   * Resolve and load @commitlint/config-conventional from node_modules.
   * Referenced packages must be installed
   */
  extends: ["@commitlint/config-conventional"],
  /*
   * Any rules defined here will override rules from @commitlint/config-conventional
   */
  rules: {
    "trailer-exists": [2, "always", "Jira:"],
  },
}

I get this

git commit -m 'foo'
yarn run v1.22.17
$ /project/node_modules/.bin/commitlint --edit .git/COMMIT_EDITMSG
⧗   input: foo
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]
✖   message must have `Jira:` trailer [trailer-exists]

✖   found 3 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

error Command failed with exit code 1.

Further info

node -v
v17.5.0
npx @commitlint/cli --version
@commitlint/cli@16.2.1

The rule was added here: #2578

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants