Closed HenryWu01 closed 1 year ago
commitlint is focusing on linting according to https://conventionalcommits.org/
If you need a different format maybe search the issues for "headerPattern", "parserPreset" and have a look at plugins.
headerPattern
Thank you for answering! I have solved this format issue. However an new issue raised during using custom plugin.
⧗ input: :zap: FIX BUG ✖ subject must not be sentence-case [subject-case]
My subject was: FIX BUG, it should be treated as upper-case, I have no idea why it was treated as sentence-case, I want my subject to be only setence case
Here is my full config:
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(:\w+:) (.+)/,
headerCorrespondence: ['type', 'subject']
}
},
plugins: [
{
rules: {
'header-match-gitmoji-pattern': (parsed) => {
const { type, subject } = parsed;
if (type === null && subject === null) {
return [false, 'Header must be in format \':gitmoji: subject\''];
}
return [true, ''];
},
'gitmoji-type-enum': (parsed, _when, expectedValue) => {
const { type } = parsed;
if (type && !expectedValue.includes(type)) {
return [false, `type must be one of ${expectedValue}, see https://gitmoji.dev`];
}
return [true, ''];
}
}
}
],
extends: [
'@commitlint/config-conventional'
],
rules: {
'header-match-gitmoji-pattern': [2, 'always'],
'gitmoji-type-enum': [2, 'always', [':adhesive_bandage:', ':alembic:', ':alien:', ':ambulance:', ':arrow_down:', ':arrow_up:', ':art:', ':beers:', ':bento:', ':bookmark:', ':boom:', ':bricks:', ':bug:', ':building_construction:', ':bulb:', ':busts_in_silhouette:', ':camera_flash:', ':card_file_box:', ':chart_with_upwards_trend:', ':children_crossing:', ':closed_lock_with_key:', ':clown_face:', ':coffin:', ':construction:', ':construction_worker:', ':dizzy:', ':egg:', ':fire:', ':globe_with_meridians:', ':goal_net:', ':green_heart:', ':hammer:', ':heavy_minus_sign:', ':heavy_plus_sign:', ':iphone:', ':label:', ':lipstick:', ':lock:', ':loud_sound:', ':mag:', ':memo:', ':money_with_wings:', ':monocle_face:', ':mute:', ':necktie:', ':package:', ':page_facing_up:', ':passport_control:', ':pencil2:', ':poop:', ':pushpin:', ':recycle:', ':rewind:', ':rocket:', ':rotating_light:', ':safety_vest:', ':see_no_evil:', ':seedling:', ':sparkles:', ':speech_balloon:', ':stethoscope:', ':tada:', ':technologist:', ':test_tube:', ':thread:', ':triangular_flag_on_post:', ':truck:', ':twisted_rightwards_arrows:', ':wastebasket:', ':wheelchair:', ':white_check_mark:', ':wrench:', ':zap:']],
'type-enum': [2, 'never'],
'subject-case': [2, 'never', ['sentence-case']]
}
}
I use never for subject-case
just for testing, it seems like commitlint have issue parsing subject format or I'm using it wrong?
In my understanding, setence-case should be something like this:
This is an example of setence case
While upper-case to be like this:
THIS IS AN EXAMPLE OF UPPER CASE
When I change to always with setence-case and pascal-case, a subject with FIX BUG UP
will pass commitlint, it's not setence nor pascal case at all.
'subject-case': [2, 'always', ['sentence-case', 'pascal-case']]
[main (root-commit) 11849de] :zap: FIX BUG UP
26 files changed, 6740 insertions(+)
Have a look how sentence-case
and pascal-case
are actually tested: https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/rules/src/subject-case.test.ts
FIX MY BUG
might just fullfill both cases without any issue.
Closing because not in commitlints scope
Expected Behavior
I perfer to use this kind of git commit message style:
For instance:
I expect commitlint to support this kind of format
Current Behavior
However, commitlint does not recognize type and subject at all and throw error:
Affected packages
Possible Solution
Maybe provider configuration in
commitlintrc
to support more type format?Context
No response