Skip to content

fix: published docker image does not behave consistently with examples from documentation #4234

Open
@naffers

Description

@naffers

Steps to Reproduce

  1. docker pull commitlint/commitlint:latest

  2. Run the container providing a string to lint: echo "foo" | docker run -i commitlint/commitlint:latest
    Result:

    echo "foo" | docker run -i commitlint/commitlint:latest
    ⧗   input: foo
    ✖   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
    
  3. Extending @commitlint/config-conventional in a file named commitlint.config.js
    Okay so I add the simplest config:

    export default {
      extends: [
        '@commitlint/config-conventional'
      ]
    }
    
  4. Then running the command but additionally volume mount this config into the container: echo "foo" | docker run -i -v $(pwd)/commitlint.config.js:/commitlint.config.js commitlint/commitlint:latest
    Result:

    export default {
    ^^^^^^
    
    SyntaxError: Unexpected token 'export'
    
  5. Switch the configuration to CJS format:

    module.exports = {
      extends: [
        '@commitlint/config-conventional'
      ]
    }
  6. Run the same command: echo "foo" | docker run -i -v $(pwd)/commitlint.config.js:/commitlint.config.js commitlint/commitlint:latest
    Result:

    ⧗   input: foo
    ✖   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
    

    Which indicates that configuration style does work.

  7. Additionally I've noticed that if you use another allowable config file name such as .commitlintrc rename the above working file to this. Change the docker run command to reference the new filename:
    echo "foo" | docker run -i -v $(pwd)/.commitlintrc:/.commitlintrc commitlint/commitlint:latest

    Result: You get a massive YAMLException: YAML Error in /.commitlintrc

Current Behavior

No response

Expected Behavior

Reading through the documentation I maybe naively expected this would behave as the locally installed version, just being ran within a container.

As highlighted above it is my experience that it has some quite different behaviour whether intentional or not.

Is the difference intentional, or should the pre-built Dockerfile behave as if you had the npm packages installed locally?

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

No response

Context

I am attempting to integrate a commitlint job within GitLab CI but the errors I've highlighted tripped me up and led me to investigate this in a bit more detail outside of that context.

I wanted to understand whether this was intentional, I'm doing something obviously wrong, or actually whether it is a bug and so I'm raising this to potentially highlight a yet undiscovered issue.

commitlint --version

19.6.0

git --version

2.47.1

node --version

18.20.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions