conventional-changelog / commitlint

📓 Lint commit messages
https://commitlint.js.org
MIT License
16.84k stars 905 forks source link

fix: commitlint doesn't support atom preset #3547

Open ffxsam opened 1 year ago

ffxsam commented 1 year ago

Expected Behavior

I've set up the CLI for local use, according to the instructions.

commitlint.config.js ```js /* eslint-disable no-undef */ // import type { UserConfig } from '@commitlint/types'; // import { RuleConfigSeverity } from '@commitlint/types'; const Configuration = { /* * Resolve and load @commitlint/config-conventional from node_modules. * Referenced packages must be installed */ extends: ['@commitlint/config-conventional'], /* * Resolve and load conventional-changelog-atom from node_modules. * Referenced packages must be installed */ parserPreset: 'conventional-changelog-atom', /* * Resolve and load @commitlint/format from node_modules. * Referenced package must be installed */ formatter: '@commitlint/format', /* * Any rules defined here will override rules from @commitlint/config-conventional */ rules: { 'type-enum': [2, 'always', ['feat', 'fix', 'chore', 'docs']], 'scope-enum': [2, 'always', ['core', 'cli', 'docs', 'test']], }, /* * Functions that return true if commitlint should ignore the given message. */ ignores: [(commit) => commit === ''], /* * Whether commitlint uses the default ignore rules. */ 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; ```

When I commit with a message like "chore(test): Perfectly valid commit message", I should at least see an error telling me the possible enums.

Current Behavior

It complains about type & subject being empty.

✔ Preparing lint-staged...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
⧗   input: chore(test): Perfectly valid commit message
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Affected packages

Possible Solution

No response

Steps to Reproduce

1. mkdir fresh && cd fresh
2. pnpm i -D @commitlint/config-conventional conventional-changelog-atom @commitlint/format @commitlint/cli
3. # copy config from above
4. echo 'chore(test): Testing' | pnpm commitlint

Context

No response

commitlint --version

@commitlint/cli@17.4.4

git --version

git version 2.39.1

node --version

v18.12.1

escapedcat commented 1 year ago

Some presets are not supported, see duplicate issue: https://github.com/conventional-changelog/commitlint/issues/298#issuecomment-368292737

knocte commented 1 year ago

Just so I understand correctly, instead of:

pnpm i -D @commitlint/config-conventional conventional-changelog-atom @commitlint/format @commitlint/cli

The workaround to this bug is to not install conventional-changelog-atom? So, like this:

pnpm i -D @commitlint/config-conventional @commitlint/format @commitlint/cli

Right?

escapedcat commented 1 year ago

I believe it's less about installing the dep but trying to use this in the commitlint-config as parserPreset: 'conventional-changelog-atom', see provided commitlint.config.js above.

lsalazarm99 commented 1 year ago

@escapedcat What config file were you referring to? The OP's one? I understand that the OP's config is the "wrong" one. But it is the one that the tool recommends.

escapedcat commented 1 year ago

@lsalazarm99 please read the comment from Mario I referred to:

Some presets are not supported, see duplicate issue: #298 (comment)

Commitlint doesn't support certain presets. At least currently.