Closed nils-van-zuijlen closed 7 months ago
Hi there, this a weird once since this module is not ESM nor it does any import
or require
. Do you have a package.json
in your project by any chance? If so can you please share it?
I do not have a project.json as the project is python.
I found out that @commitlint/config-angular and other configs backed by their repo recently (in v19) switched to ESM, so it may be related.
https://github.com/conventional-changelog/commitlint/releases/tag/v19.0.0
I found out that @commitlint/config-angular and other configs backed by their repo recently (in v19) switched to ESM, so it may be related.
https://github.com/conventional-changelog/commitlint/releases/tag/v19.0.0
Yeah that's probably it, ESM interop is always fun. I guess I could modify this package to be ESM by adding type: module
but that might have unintended consequences.
Any workaround for the time being? Experiencing same thing, here's our config:
const Configuration = {
extends: ['@commitlint/config-conventional'],
rules: {
"header-max-length": [2, "always", 72], // To show full header in github
"subject-case": [2, "always", "sentence-case"], // To look consistent in auto-generated changelog
"scope-enum": [2, "always"],
},
/*
* Array of functions that return true if commitlint should ignore the given message.
* Given array is merged with predefined functions, which consist of matchers like:
*
* - 'Merge pull request', 'Merge X into Y' or 'Merge branch X'
* - 'Revert X'
* - 'v1.2.3' (ie semver matcher)
* - 'Automatic merge X' or 'Auto-merged X into Y'
*
* To see full list, check https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts.
* To disable those ignores and run rules always, set `defaultIgnores: false` as shown below.
*/
ignores: [(commit) => commit === ''],
/*
* Whether commitlint uses the default ignore rules, see the description above.
*/
defaultIgnores: true,
/*
* Custom URL to show upon failure
*/
helpUrl:
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
/*
* Custom prompt configs
*/
prompt: {
messages: {},
questions: {
type: {
description: 'please input type:',
},
},
},
};
module.exports = Configuration;
commitlint...............................................................Failed
- hook id: commitlint
- exit code: 1
/home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/cli/lib/cli.js:123
throw err;
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/@commitlint/config-conventional/lib/index.js from /home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/resolve-extends/lib/index.js not supported.
Instead change the require of /home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/@commitlint/config-conventional/lib/index.js in /home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/resolve-extends/lib/index.js to a dynamic import() which is available in all CommonJS modules.
at /home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/resolve-extends/lib/index.js:48:19
at Array.reduce (<anonymous>)
at loadExtends (/home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/resolve-extends/lib/index.js:45:16)
at resolveExtends (/home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/resolve-extends/lib/index.js:25:22)
at load (/home/mcampbell/.cache/pre-commit/repo9t8os46x/node_env-default/lib/node_modules/commitlint-pre-commit-hook/node_modules/@commitlint/load/lib/load.js:42:52) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v21.6.2
Hey, could you both please try with this tag and see if that sorts the issue?
Works for me with:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: esm # This is a workaround for https://github.com/alessandrojcm/commitlint-pre-commit-hook/issues/152
hooks:
- id: commitlint
stages:
- commit-msg
additional_dependencies:
- '@commitlint/config-conventional'
Works for me too.
(k8s-billing-py3.11) (⎈|default:k8s-billing)mcampbell-1➜ ~/github/coreweave/k8s-billing : mc/fix-org-target ✘ :✚ ᐅ git commit -m "refactor: Increase default log level to INFO"
[WARNING] The 'rev' field of repo 'https://github.com/alessandrojcm/commitlint-pre-commit-hook' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
[INFO] Initializing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook.
[INFO] Initializing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook:@commitlint/config-conventional.
check for added large files..............................................Passed
check python ast.........................................................Passed
check for case conflicts.................................................Passed
check for merge conflicts................................................Passed
check json...........................................(no files to check)Skipped
check yaml...............................................................Passed
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for case conflicts.................................................Passed
black....................................................................Passed
isort....................................................................Passed
pycln....................................................................Passed
prettier.................................................................Passed
pyupgrade................................................................Passed
markdownlint-fix-docker..............................(no files to check)Skipped
[WARNING] The 'rev' field of repo 'https://github.com/alessandrojcm/commitlint-pre-commit-hook' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
[INFO] Installing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
commitlint...............................................................Passed
[mc/fix-org-target 4c48f3a] refactor: Increase default log level to INFO
2 files changed, 2 insertions(+), 2 deletions(-)
Wow, I was going to pop in here to let you know version pinning the config dependency, such as additional_dependencies: ['@commitlint/config-conventional@18.6.2']
is a viable temporary workaround... but Alessandro is already on the proper fix!
Great I'll see about mergin it into master, it should be fine since ESM is supposed to be able to import CJS but weird things tend to happen.
Just verified against 46ad8d10517771202384ef846ec4a5aa17e6ad26, works without any problems. Looking forward to the release.
Thanks for your work @alessandrojcm!
Released on v9.13.0
Installing with the following
.pre-commit-config.yaml
fails with an error.The error, with home path anonymized with $HOME:
Our
commitlint.config.js
: