Getting started
Install
Install @commitlint/cli and a @commitlint/config-* / commitlint-config-* of your choice as devDependency and configure commitlint to use it.
npm install -D @commitlint/cli @commitlint/config-conventionalyarn add -D @commitlint/cli @commitlint/config-conventionalpnpm add -D @commitlint/cli @commitlint/config-conventionalbun add -d @commitlint/cli @commitlint/config-conventionaldeno add -D npm:@commitlint/cli npm:@commitlint/config-conventionalConfiguration
Configure commitlint to use conventional config
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.jsNOTE
Windows users: The echo command in PowerShell and cmd.exe may create the config file with a non-UTF-8 encoding (e.g. UTF-16LE or the system's default ANSI code page), which can cause commitlint to fail to read the configuration. To avoid this, create commitlint.config.js manually in your editor, or use PowerShell with explicit encoding:
"export default { extends: ['@commitlint/config-conventional'] };" | Out-File -Encoding utf8 commitlint.config.jsWARNING
Node v24 changes the way that modules are loaded, and this includes the commitlint config file. If your project does not contain a package.json, commitlint may fail to load the config, resulting in a Please add rules to your commitlint.config.js error message. This can be fixed by doing either of the following:
- Add a
package.jsonfile, declaring your project as an ES6 module. This can be done easily by runningnpm init es6. - Rename the config file from
commitlint.config.jstocommitlint.config.mjs.
Refer to configuration documentation for more information.