Skip to content

feat: exit with a code >3 when configuration is missing or incomplete #4142

Closed
@ferrarimarco

Description

@ferrarimarco

Expected Behavior

Exit with a code that's greater than 0, and different from 1, 2, and 3 when the configuration from the CLI is incomplete (such as when missing --extends), or when there's no configuration file.

Current Behavior

Commitlint exits with an exit code equal to 1 when there are configuration errors or when there are linting errors. This makes it impossible to differentiate between linting issues and commitlint configuration issues.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

I don't know much about commitlint implementation to suggest a possible design. :(

I'm suggesting something different from:

  • 1 (commit linting errors)
  • 2 and 3 (commit linting errors and warnings in strict mode)

Context

Steps to reproduce the behavior:

  1. mkdir /tmp/test-commitlint

  2. cd /tmp/test-commitlint

  3. git init

  4. touch test.txt

  5. git add test.txt

  6. git commit -m "Initial commit"

  7. commitlint --last

    Output (expected):

    ⧗   input: Initial commit
    ✖   Please add rules to your `commitlint.config.js`
        - Getting started guide: https://commitlint.js.org/guides/getting-started
        - Example config: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/src/index.ts [empty-rules]
    
    ✖   found 1 problems, 0 warnings
    ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
    
  8. echo $?

    1
    
  9. commitlint --version

    Output:

    @commitlint/[email protected]
    

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions