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

fix(config-conventional): use default export #3911

Conversation

dargmuesli
Copy link
Contributor

@dargmuesli dargmuesli commented Feb 13, 2024

Description

Resolves #3909

Motivation and Context

Reverts the new config export.

Usage examples

n/a

How Has This Been Tested?

locally

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@@ -4,7 +4,7 @@ import {
TargetCaseType,
} from '@commitlint/types';

export const config = {
export default {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like this also work? To have both? If this makes sense

export const config = {...}
export default config;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would prevent introducing another breaking change. 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should work, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, checking it now I don't think that'll work. There can only be one export = which seems to be needed for the fix, unless I don't know of some TypeScript compiler option magic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added an ESM wrapper which may help in this case.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adding tests for:

  • CommonJS project using require()
  • ESM project using import

But I do not know how to do it without creating two projects with package.json and so on locally importing the transpiled files from config-conventionnal.
I do not know if node.js project mocking exists in test tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had to readd main because some existing test required it.

@dargmuesli dargmuesli marked this pull request as ready for review February 13, 2024 15:05
@knocte
Copy link
Contributor

knocte commented Feb 14, 2024

Can you guys add regression tests so that this doesn't happen again?

@jerome-benoit
Copy link

jerome-benoit commented Feb 14, 2024

Can you guys add regression tests so that this doesn't happen again?

The regression test for default export test was already there and covers already TS use case (which includes direct ESM or CommonJS use case depending on the project package.json "module" field), but the PR causing the regression modified it to "fix" test failures and the PR review fails to detect the related breaking changes.

Since it's a major regression introduced in a patch level version release, any enhancements to mitigate human errors at export/import changes for that package with tests should be postponed to later and the priority should be to release a patch level version fixing the regression.

@knocte
Copy link
Contributor

knocte commented Feb 14, 2024

Since it's a major regression introduced in a patch level version release, any ... should be postponed to later and the priority should be to release...

I agree with this, but you just needed to say that this PR is actually modifying tests too, which I hadn't caught before. So, utACK from me.

@jerome-benoit
Copy link

jerome-benoit commented Feb 14, 2024

Since it's a major regression introduced in a patch level version release, any ... should be postponed to later and the priority should be to release...

I agree with this, but you just needed to say that this PR is actually modifying tests too, which I hadn't caught before. So, utACK from me.

The complete context usually helps at taking wise decision.

In its current state, the UTs still not cover all import use cases like import from CommonJS or ESM only projects. But I guess an issue can be created to ensure it will be planned: transpile the TS index. ... test to CommonJS and ESM with the proper file extension and also run them.

@escapedcat escapedcat merged commit bc48408 into conventional-changelog:master Feb 14, 2024
5 checks passed
@escapedcat
Copy link
Member

Thanks everyone! Exciting times.
Will create a release and hope for the best.

@escapedcat
Copy link
Member

https://github.com/conventional-changelog/commitlint/releases/tag/v18.6.2

benoitf added a commit to benoitf/desktop that referenced this pull request Feb 14, 2024
fix bug in 18.6.1 where it was throwing an error on commit

Bug Fixes
fix(config-conventional): use default export by @dargmuesli
conventional-changelog/commitlint#3911

Signed-off-by: Florent Benoit <fbenoit@redhat.com>
@dargmuesli dargmuesli deleted the fix/config-conventional/export branch February 14, 2024 21:25
benoitf added a commit to containers/podman-desktop that referenced this pull request Feb 15, 2024
fix bug in 18.6.1 where it was throwing an error on commit

Bug Fixes
fix(config-conventional): use default export by @dargmuesli
conventional-changelog/commitlint#3911

Signed-off-by: Florent Benoit <fbenoit@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

fix: commitlint --extends is ignored for commitlint/config-conventional (v18.6.1)
5 participants