Skip to content

[Question] how to extend and override config-conventional settings #2232

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
padamstx opened this issue Oct 23, 2020 · 4 comments
Closed

[Question] how to extend and override config-conventional settings #2232

padamstx opened this issue Oct 23, 2020 · 4 comments
Labels

Comments

@padamstx
Copy link

Hi, this is just a simple usage question.

I currently define a .commitlintrc.yml file with the following contents:

extends:
    - '@commitlint/config-conventional'

Currently, this commit message (feat(CLI): add annotation for the flag name for a parameter/property in the CLI) fails commitlint validation with error: scope must be lower-case [scope-case]

I'd like to relax this restriction to allow the component (i.e. "CLI") to be specified in upper case so that the above commit message passes validation.
Could someone please suggest how to configure that in my .commitlintrc.yml file?

Your Environment

Executable Version
commitlint --version 11.0.0
git --version 2.62.2
node --version 12.18.3
@escapedcat
Copy link
Member

escapedcat commented Oct 26, 2020

Hey @padamstx , have a look at the docs here: https://commitlint.js.org/#/reference-configuration?id=configuration
There's an example that says:

  /*
   * Any rules defined here will override rules from @commitlint/config-conventional
   */
  rules: {
    'type-enum': [2, 'always', ['foo']],
  },

Try to overwrite the specific rule like this but using the rule you want to overwrite:
https://commitlint.js.org/#/reference-rules?id=scope-case

Hope this helps. Let us know if you need further help.

@padamstx
Copy link
Author

Just to close the loop on this, I finally got around to using this info to modify our commitlint config.
This is the commitlint.config.js file I ended up with:

const Configuration = {

  extends: ['@commitlint/config-conventional'],

  /*
   * Any rules defined here will override rules from @commitlint/config-conventional
   */
  rules: {
    'scope-case': [0, 'always', 'lower-case'],
    'subject-case': [0, 'always', 'lower-case'],
  },
};

module.exports = Configuration;

I initially had the first line coded like this:

const Configuration: Config = {

which is what was specified in the example Configuration object
but that caused a javascript syntax error. I'm not a javascript expert, but a quick google search led me to just remove the : Config part, and commitlint seemed to be perfectly happy with that.
I mention this in case the example needs to be corrected.

Anyway, thank you for the info @escapedcat !

@escapedcat
Copy link
Member

Uhm, yeah, that's typescript, but the docs say commitlint.config.js which isn't compatible in a non-TS setup I guess. Thanks for lettign us know. We will try to update the docs here.

@escapedcat
Copy link
Member

@padamstx would this help?:
#2424

escapedcat added a commit that referenced this issue Jan 29, 2021
* docs: show config example in ts and js #2232

* docs: import config type from types #2232
tim-stasse pushed a commit to tim-stasse/commitlint that referenced this issue Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants