-
Notifications
You must be signed in to change notification settings - Fork 909
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
Add support to .cjs
(common) and .mjs
(module) config file
#2742
Comments
Happy if you want to create a PR for this. Docs should also be updated then: |
Just out of curiousity why does commitlint override the searchPlaces instead of just using the ones provided by cosmiconfig? These all seem like the built in configs other than the typescript ones which can be configured with a custom loader like you are already. Just curious if there was something I'm missing here and can learn from this code. |
@k2snowman69 no worries, good point! |
@k2snowman69 But the custom loaders are just an object map for items in searchPlaces reference to cosmiconfig, custom loaders will be merged with the defaults but the search places should override. Also I think it would be beneficial to specify this searchPlaces configuration for the display. If you want to change the loading behavior of the configuration but don't know cosmiconfig, you may have to spend some time finding the file and forking it to modify, but adding |
I'm fairly sure that if you add a custom loader with an extension, cosmiconfig will add that extension to the list of extensions to search. Here's the unit test for it.
This is the part I disagree with. I was debugging for near about 6 hours trying to figure out why even though commitlint used cosmiconfig it didn't use it's available configurations. I had to dig into commitlint's code base to figure out you were providing custom searchPlaces which overrides cosmiconfigs defaults. I agree from a documentation standpoint in the configuration section stating "we support several file extensions like cosmiconfig.config.ts, .cosmiconfigrc.js, cosmiconfigrc.json, and others via cosmiconfig". This way you're still documenting some more used file names but as cosmiconfig changes it's support you aren't having to make a code change along side them every time. |
@k2snowman69 I understand this. If the searchplaces-defaults can be merged automatically with the extra This could be a done in a separated PR. Unless @gustavonobreza wants to add this as well. |
I agree to change searchPlaces to the default configuration. But the This change for searchPlaces can be merged with #2779, as there is no actual feature change. I will later on open a pr that solves both problems. Thanks @k2snowman69 for the suggestion. |
v13.2.0 was technically a breaking change — in v13.1.0 (before #2698), It was quite confusing for me who just ran
|
@k2snowman69 I just tried to remove the searchplace config but found that the ts-loader was not being processed correctly. const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
const explore = explicitPath ? explorer.load : explorer.search;
const searchPath = explicitPath ? explicitPath : cwd;
const local = await explore(searchPath); This unit test just coverages So in order to be able to recognize the Please correct me if I'm wrong, maybe I'm missing something in my review of the code. |
It was my mistake. In the pr at the time we discussed about the support of cjs. My opinion is that cosmiconfig currently does not support esm. The distinction between However, in fact when In case this happens in the future, for example, cosmiconfig supports |
This comment has been minimized.
This comment has been minimized.
This is to workaround conventional-changelog/commitlint#2742.
This is to workaround conventional-changelog/commitlint#2742.
This is to workaround conventional-changelog/commitlint#2742.
This is to workaround conventional-changelog/commitlint#2742.
This is to workaround conventional-changelog/commitlint#2742.
Expected Behavior
If config file is
commitlint.config.mjs
orcommitlint.config.cjs
is expected that worksCurrent Behavior
Is ignored
Affected packages
Possible Solution
in
commitlint/@commitlint/load/src/utils/load-config.ts
at loadConfig:The text was updated successfully, but these errors were encountered: