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

feature: add flag to enable/disable multiple-scopes (default: enabled) #4015

Open
1 of 4 tasks
wlc015f opened this issue Apr 9, 2024 · 13 comments
Open
1 of 4 tasks
Labels

Comments

@wlc015f
Copy link

wlc015f commented Apr 9, 2024

Expected Behavior

our projects previous use scope like: feat(A/B): commit msg, B is a sub scope of A.

when we update @commitlint/cli from 8.3.5 to 19.2.1 , it doesn't work well as before, because for version 19.2.1 "/" is scopes delimiter to divide input scope string into several scopes.

Current Behavior

scopeEnum would divide input scope "A/B" to scope "A" and "B" to check if input scope in commitlint config rules scope-enum, we previous config scope "A/B" can not pass isScopeInEnum check.

Steps to reproduce

  1. nodejs project with @commitlint/cli 19.2.1 and husky 9.0.11
  2. set husky hooks commit-msg npx --no -- commitlint --edit $1
  3. project commitlint.config.js is
module.exports = {
    extends: [...],
    rules: {
        "scope-empty": [2, "never"],
        "scope-enum": [2, "always", ["workload/record"]]
    }
}
  1. make some changes and commit code with message test(workload/record): test commit , then get error message below:
% git commit -m "test(workload/record): test commit" 
🔍  Finding changed files since git revision af2ddf4d.
🎯  Found 1 changed file.
✅  Everything is awesome!
⧗   input: test(workload/record): test commit
✖   scope must be one of [workload, workload/record,...] 

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

husky - commit-msg script failed (code 1)

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

set scopes delimiter as a optional config for user may solve this problem, if user do not config scopes delimiter, it will works well as before.

Context

#701 (comment)

@wlc015f wlc015f added the feature label Apr 9, 2024
@escapedcat
Copy link
Member

Which version did you use before?
Can you show some terminal output to make your issue more understandable.
And update the title to describe your issue better.
Thanks!

@wlc015f wlc015f changed the title feat: scopes delimiter configurable fix: update @commitlint/cli from 8.3.5 to 19.2.1 get error when commit scope with '/' Apr 9, 2024
@escapedcat
Copy link
Member

Thanks for clarifying your issue!

The update from 8.3.5 to 19.2.1 has several breaking issues.
#901 was added in v9 and might cause your issue.

Looking at it now it would have been good to add a flag to enable/disable on multiple scopes. Might have even been a breaking change I guess but we didn't notice.

Maybe adding such flag would help in your situation?

@wlc015f
Copy link
Author

wlc015f commented Apr 10, 2024

Thanks for clarifying your issue!

The update from 8.3.5 to 19.2.1 has several breaking issues. #901 was added in v9 and might cause your issue.

Looking at it now it would have been good to add a flag to enable/disable on multiple scopes. Might have even been a breaking change I guess but we didn't notice.

Maybe adding such flag would help in your situation?

yeah, a switch flag will solve my situation.

@escapedcat
Copy link
Member

Would you be able to create a PR?

@escapedcat escapedcat changed the title fix: update @commitlint/cli from 8.3.5 to 19.2.1 get error when commit scope with '/' feature: add flag to enable/disable multiple-scopes (default: enabled) Apr 10, 2024
@wlc015f
Copy link
Author

wlc015f commented Apr 10, 2024

Would you be able to create a PR?

I'd like to try

@knocte
Copy link
Contributor

knocte commented Apr 11, 2024

@wlc015f I still don't grasp the issue here because you missed the "Steps to reproduce" part, can you at least attach the commitlint configuration you were using?

@wlc015f
Copy link
Author

wlc015f commented Apr 11, 2024

@wlc015f I still don't grasp the issue here because you missed the "Steps to reproduce" part, can you at least attach the commitlint configuration you were using?

add the details above

@wlc015f
Copy link
Author

wlc015f commented Apr 11, 2024

to Implement the feature, I have looked over the relevant code, and prefer to place the code related to parse message scopes with config under the @commitlint/parse module or into the conventional-commits-parser package, function scopeEnum should just validate the rules with input config with parsed data. i need some advice/guidance @escapedcat @knocte

@knocte
Copy link
Contributor

knocte commented Apr 16, 2024

under the @commitlint/parse module or into the conventional-commits-parser package

Yeah, I guess you should aim at creating a PR here: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser

to Implement the feature,

BTW, if I understood this ticket correctly, this is a bug, not a feature.

@escapedcat
Copy link
Member

Yes, I guess it was a breaking change because multiple scopes were added "enabled by default", right?
But it's done already... so I guess this "feature" is the best option?

@wlc015f
Copy link
Author

wlc015f commented Apr 16, 2024

BTW, if I understood this ticket correctly, this is a bug, not a feature.

Yes, I guess it was a breaking change because multiple scopes were added "enabled by default", right? But it's done already... so I guess this "feature" is the best option?

I think it should be worked on as a feature.

@escapedcat
Copy link
Member

Would you be able to create a PR?

@wlc015f
Copy link
Author

wlc015f commented Apr 19, 2024

Would you be able to create a PR?

I'd like to try this weekend

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

3 participants