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.

Unable to commit when type-enum is overridden

See original GitHub issue

I’m not able to do a commit when I override the type-enum rule in commitlint.config.js.

When I don’t override the type-enum rule a commit is not blocked.

Expected Behavior

The commit should be done.

Current Behavior

When I do a commit with using an approved type, I still get an error message:

echo 'feat(hello): bar' | commitlint
⧗   input: feat(hello): bar
✖   type must be one of [feat,fix,docs,style,refactor,test,revert,content] [type-enum]

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

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Steps to Reproduce (for bugs)

  1. Create commitlint.config.js with the config I put above
  2. Run commitlint and see the magic happen
commitlint.config.js ```js module.exports = { extends: ['@commitlint/config-conventional'], rules: { 'type-enum': [ 2, 'always', [ [ 'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'revert', 'content', // For articles, tutorials, etc... ], ], ], }, } ```

Context

I would like to create a custom type for articles and tutorials on my blog.

Your Environment

Executable Version
commitlint --version @commitlint/cli@11.0.0
git --version git version 2.21.1 (Apple Git-122.3)
node --version v15.5.0

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
armano2commented, Jan 12, 2021

@johanvergeer @escapedcat this is not a bug, your configuration is incorrect, as enum values you must provide array, not array of arrays

module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      [
-        [
-          'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'revert', 'content', // For articles, tutorials, etc...
-        ],
+        'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'revert', 'content', // For articles, tutorials, etc...
      ],
    ],
  },
};

2reactions
joaomellogomescommented, Jun 3, 2021

@armano2 thanks for you answer, it helped me to understad how I can extend the commitlint rules and also thanks for @johanvergeer

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Can I extend a class and override enclosed enum type?
You can't extend enum . enums are essentially a final class. However, enums can implement, so combined with generics, you get:
Read more >
How to Write Good Commit Messages with Commitlint
This would require me to override the type-enum rule in the conventional commits convention. You should get the above output.
Read more >
commitlint - Lint commit messages
Lint from stdin echo 'foo: bar' | commitlint ⧗ input: foo: bar ✖ type must ... fix, perf, refactor, revert, style, test] [type-enum]...
Read more >
C++ Core Guidelines - GitHub Pages
The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++.
Read more >
Hibernate ORM 5.4.33.Final User Guide - Red Hat on GitHub
Hibernate supports the mapping of Java enums as basic value types in a number of different ... which was not set until the...
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