-
Notifications
You must be signed in to change notification settings - Fork 908
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
commitlint does not find plugin when a relative path is provided #932
Comments
Yes, this should work if we expect plugins to be used. |
As a workaround you can try passing down an absolute path, e.g.: // commitlint.config.js
{
plugins: [require.resolve('./dir/my-custom-plugin.js')],
} |
The absolute path doesn't work either, for the same reason (it's assuming that it's a module name and prepending
|
Ah thanks for pointing this out. I think this creates two bodies of work for us:
|
I think I have run into this issue as well, albeit in different use case. I am building a tool to provide "conventional release" services to projects across company and most of them are not based on NPM. So what I am doing is building a docker image to be used in CI. package.json: {
"name": "conventional-release",
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"semantic-release": "^17.0.4",
"@semantic-release/git": "^9.0.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/gitlab": "^6.0.3",
"conventional-changelog-conventionalcommits": "^4.2.3",
"@commitlint/config-conventional": "^8.3.4",
"@commitlint/cli": "^8.3.5"
}
} Dockerfile: FROM docker:git
ENV NODE_VERSION 12.15.0
ENV YARN_VERSION 1.19.2
RUN apk add --no-cache nodejs npm yarn
WORKDIR /opt
ENV PATH="/opt/node_modules/.bin:${PATH}"
COPY package.json .
COPY yarn.lock .
RUN yarn --prod && \
yarn autoclean --init && \
yarn autoclean --force && \
rm package.json yarn.lock .yarnclean Now running this results in $ npx commitlint --from=$CI_MERGE_REQUEST_TARGET_BRANCH_SHA
/opt/node_modules/@commitlint/cli/lib/cli.js:124
throw err;
^
Error: Cannot find module "@commitlint/config-conventional" from "/builds/dotnet-demo"
at resolveId (/opt/node_modules/@commitlint/resolve-extends/lib/index.js:97:15)
at resolveConfig (/opt/node_modules/@commitlint/resolve-extends/lib/index.js:80:24)
at /opt/node_modules/@commitlint/resolve-extends/lib/index.js:37:24
at Array.reduce (<anonymous>)
at loadExtends (/opt/node_modules/@commitlint/resolve-extends/lib/index.js:35:38)
at resolveExtends (/opt/node_modules/@commitlint/resolve-extends/lib/index.js:22:20)
at Object.<anonymous> (/opt/node_modules/@commitlint/load/lib/index.js:65:44) {
code: 'MODULE_NOT_FOUND'
} Note that semantic release modules work as expected. |
thats not fully true, we should support also windows absolute paths eg. |
Currently there is a way to load local plugins by simply require'ing it // commitlint.config.js
{
plugins: [require('./dir/my-custom-plugin.js')],
} |
Expected Behavior
Currently, it seems that plugins can only be resolved if they're an npm package inside of the node_modules folder (node resolution logic). If I try to load a plugin using a relative path, I get this error:
Relative paths are supported for the
extends
andparserPreset
keys, so making this work would align that behavior withplugins
too.Current Behavior
I would love to be able to write this and just have it work.
Affected packages
Possible Solution
Looking at how the parserPreset key is being loaded, it seems like it's just a matter of using
resolveFrom
beforerequire
ing the plugin.Context
I basically want to have a small custom rule in a single file, but it seems like a hassle to either handle two separate packages or set up lerna or something.
Your Environment
commitlint --version
git --version
node --version
The text was updated successfully, but these errors were encountered: