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

Sharing configurations that use plugins does not work #1942

Closed
1 of 4 tasks
juliuscc opened this issue Jun 17, 2020 · 3 comments · Fixed by #1976
Closed
1 of 4 tasks

Sharing configurations that use plugins does not work #1942

juliuscc opened this issue Jun 17, 2020 · 3 comments · Fixed by #1976
Labels

Comments

@juliuscc
Copy link
Contributor

juliuscc commented Jun 17, 2020

Sharing configurations that use plugins does not work

We are trying to share a company-wide config so that we can easily have a standard linter with just one line in package.json. We want to use a plugin that adds a rule that otherwise doesn't exist.

  • I have tried our config in a test repo, and then it works great! Thanks for the great tool! ✅
  • When I publish the config on npm without the plugin, I can extend it from other projects. ✅
  • When I publish the config on npm with the plugin, committlint does not recognize the rule. ❌

The configuration looks like this:

const types = require('conventional-commit-types').types;

module.exports = {
  extends: ['@commitlint/config-conventional'],
  plugins: ['subject'],
  rules: {
    'scope-empty': [2, 'always'],
    'type-enum': [2, 'always', Object.keys(types)],
    'subject-case': [0, 'always'],
    'subject-regexp': [2, 'always', /^DAZ-\d+\s.*/],
  },
};

The plugin is commitlint-plugin-subject and we use it to enforce that we can put a JIRA-issue at the beginning of a subject line. Like fix: DAZ-123 Remove bugs.

Expected Behavior

I expect the commit fix: DAZ-123 Remove bugs to pass, and the rule 'subject-regexper' to be recognized.

Current Behavior

When I extend the configuration and run a commit like fix: DAZ-123 Remove bugs I get the following error:

❯ git commit -m "fix: DAZ-123 Remove bugs"
husky > commit-msg (node v13.9.0)
/Users/julius.celik/Coding/temp/commitlint-test/node_modules/@commitlint/cli/lib/cli.js:124
        throw err;
        ^

RangeError: Found invalid rule names: subject-regexp. 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/julius.celik/Coding/temp/commitlint-test/node_modules/@commitlint/lint/lib/index.js:76:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
husky > commit-msg hook failed (add --no-verify to bypass)

Affected packages

I am not sure but I think it is a core-issue.

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

I am not sure. We really want a fix for this so If you point me in the right direction I could look into submitting a PR tomorrow.

Steps to Reproduce (for bugs)

  1. Init a new repo by running npm init -y && git init
  2. Install commitlint and husky by running npm i -D husky @commitlint/cli
  3. Install our config by running npm install @digitalroute/commitlint-config -D
  4. Run the following echo "module.exports = {extends: ['@digitalroute/commitlint-config']};" > commitlint.config.js
  5. Add the following to package.json: "husky": { "hooks": {"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}}
  6. Try to run git commit -m "fix: DAZ-123 Remove bugs"

If you do npm install @digitalroute/commitlint-config -D you get the following config:

const types = require('conventional-commit-types').types;

module.exports = {
  extends: ['@commitlint/config-conventional'],
  plugins: ['subject'],
  rules: {
    'scope-empty': [2, 'always'],
    'type-enum': [2, 'always', Object.keys(types)],
    'subject-case': [0, 'always'],
    'subject-regexp': [2, 'always', /^DAZ-\d+\s.*/],
  },
};

You can modify it in node_modules if necessary. If you comment out subject_regexp: ... and plugins: ['subject'], It should work to do a commit.

Context

We want to run a regex on the subject line. The goal is to enforce that all our issues start with 'DAZ-\d+'

Your Environment

Executable Version
@commitlint/cli --version 8.3.5
git --version git version 2.17.2 (Apple Git-113)
node --version v13.9.0
@escapedcat escapedcat added the bug label Jun 17, 2020
@escapedcat
Copy link
Member

Hey @juliuscc, thanks for the issue! Not sure when we have time to look into this or point at directions. You could ask in the chat: https://devtoolscommunity.herokuapp.com

@juliuscc
Copy link
Contributor Author

Just a status update. We got higher priority tasks so I have not looked too much at this. I will most likely start looking at this by the end of this week or next week. Before I do so I just want a confirmation: Is committing supposed to work as I expected it to?

@escapedcat
Copy link
Member

Maybe @byCedric finds some time to give you a hint for this, when he's back. Might be better to wait for his feedback before you dig into this.

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

Successfully merging a pull request may close this issue.

2 participants