commitlint does not find plugin when a relative path is provided
See original GitHub issueExpected 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:
Error: Failed to load plugin ./plugins/my-custom-plugin.js: Cannot find module 'commitlint-plugin-./plugins/my-custom-plugin.js'
Relative paths are supported for the extends
and parserPreset
keys, so making this work would align that behavior with plugins
too.
Current Behavior
I would love to be able to write this and just have it work.
{
plugins: ['./dir/my-custom-plugin.js'],
...
}
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
Looking at how the parserPreset key is being loaded, it seems like it’s just a matter of using resolveFrom
before require
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
Executable | Version |
---|---|
commitlint --version |
8.2.0 |
git --version |
git version 2.23.0 |
node --version |
v12.10.0 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How do I get lint-staged working with Husky version 6
Based on this husky github issue, just do these steps to make it work(we did it and it is working ... Finally, add...
Read more >babel-plugin-module-resolver-tsconfig - npm package - Snyk
By trying to get the babel config file path from CLI if provided. Otherwise the calling module (babel config file). If no config...
Read more >commitlint - Visual Studio Marketplace
config.file. Path to a commitlint configuration file. Relative paths are resolved based on the workspace root. Leave blank to auto-detect.
Read more >Commitizen - GitHub Pages
If your repo is Commitizen friendly: Simply use git cz or just cz instead of git commit when committing. You can also use...
Read more >Options - Stylelint
Use this option if you don't want Stylelint to search for a configuration file. The path should be either absolute or relative to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thats not fully true, we should support also windows absolute paths eg.
C:\DEV\....
Currently there is a way to load local plugins by simply using require’ing it