Skip to content

fix: @commitlint/parse package logic appears incorrect #3784

Closed
@silversonicaxel

Description

@silversonicaxel

Expected Behavior

These two following tests

  • 'scope-enum with multiple scopes should error on message with forbidden enum'
  • 'scope-enum with multiple scopes should error on message with superfluous scope'

coming from https://github.com/conventional-changelog/commitlint/blob/renovate/conventional-changelog-angular-7.x/%40commitlint/rules/src/scope-enum.test.ts are adapting to some wrong behaviour of @commitlint/parse/ package:

It seems that:

  • For 'always', the validation should pass only if the message includes all the given scopes. Otherwise, it should fail. (currently implemented)
  • For 'never', the validation should fail if the message includes any of the given scopes. Otherwise, it should pass.

Here #3725 some reference of the process of finding out the effect of the issue, not the cause.

Fixing this error will require a refactoring of tests here too https://github.com/conventional-changelog/commitlint/blob/renovate/conventional-changelog-angular-7.x/%40commitlint/rules/src/scope-enum.test.ts

Once this error is covered, conventional changelog angular 7.x could be finally released and this could resolve these issues #3698 and release-it/conventional-changelog#70

Current Behavior

This seems a wrong logic.

test('scope-enum with multiple scopes should error on message with forbidden enum', async () => {
  const [actual, message] = scopeEnum(await parsed.multiple, 'never', [
    'bar',
    'qux',
  ]);
  const expected = true;
  expect(actual).toEqual(expected);
});

test('scope-enum with multiple scopes should error on message with superfluous scope', async () => {
  const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar']);
  const expected = true;
  expect(actual).toEqual(expected);
});

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

To investigate

Steps to Reproduce

1. Run `yarn test scope-enum` and check the logic of the tests mentioned above

Context

All starts here release-it/conventional-changelog#70

commitlint --version

18.2.0

git --version

2.39.2 (Apple Git-143)

node --version

v18.18.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions