Skip to content

Unable to commit when type-enum is overridden #2384

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

Closed
2 of 4 tasks
johanvergeer opened this issue Dec 30, 2020 · 5 comments
Closed
2 of 4 tasks

Unable to commit when type-enum is overridden #2384

johanvergeer opened this issue Dec 30, 2020 · 5 comments

Comments

@johanvergeer
Copy link

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/[email protected]
git --version git version 2.21.1 (Apple Git-122.3)
node --version v15.5.0
@escapedcat escapedcat added the bug label Dec 31, 2020
@armano2
Copy link
Contributor

armano2 commented 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...
      ],
    ],
  },
};

@escapedcat
Copy link
Member

Ugh, thanks @armano2 ! @johanvergeer can you check and close if this solves your issue? Thanks

@johanvergeer
Copy link
Author

I feel like a real noob right now. Thanks @armano2

@escapedcat
Copy link
Member

@johanvergeer welcome to my world :D

@joaomellogomes
Copy link

joaomellogomes commented 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

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

4 participants