Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parserPreset in .commitlintc.json is ignored #4091

Open
2 of 4 tasks
gegenschall opened this issue Jun 19, 2024 · 4 comments
Open
2 of 4 tasks

parserPreset in .commitlintc.json is ignored #4091

gegenschall opened this issue Jun 19, 2024 · 4 comments

Comments

@gegenschall
Copy link

gegenschall commented Jun 19, 2024

Steps to Reproduce

  1. Create .commitlintrc.json with the following contents
{
  "extends": ["@commitlint/config-conventional"],
  "parserPreset:": {
    "parserOpts": {
      "issuePrefixes": ["PREFIX-"]
    }
  },
  "rules": {
    "references-empty": [2, "never"]
  }
}
  1. Run echo "feat: some feature (PREFIX-123)" | npx commitlint and observe how an error for empty references is thrown.
  2. Run npx commitlint --print-config and observe how parserPreset.parserOpts.issuePrefixes is [ '#' ].

With a commitlint.config.js this does not happen.

Current Behavior

see above.

Expected Behavior

It should correctly pick up parserPreset from the JSON configuration.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

No response

Context

No response

commitlint --version

@commitlint/[email protected]

git --version

2.45.2

node --version

v20.13.1

@knocte
Copy link
Contributor

knocte commented Jul 6, 2024

and observe how an error for empty references is thrown.

Please copy+paste that error.

@gegenschall
Copy link
Author

Uhm, sure:

⧗   input: feat: some feature (PREFIX-123)
✖   references may not be empty [references-empty]

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

If you want a repro, see this repo.

@escapedcat

This comment was marked as outdated.

@krema
Copy link

krema commented Oct 17, 2024

I have created a sharable config and need to overwrite the parser options.

I found a workaround to overwrite the @commitlint/config-conventional parserOpts presets without losing them.

index.js

import { resolveFrom } from '@commitlint/load';

// Resolve and import the conventional config
const conventionalConfigPath = resolveFrom('@commitlint/config-conventional', process.cwd());
const conventionalConfig = (await import(conventionalConfigPath)).default;

// Resolve and import the conventional parser options
const conventionalParserOptsPath = resolveFrom('conventional-changelog-conventionalcommits', process.cwd());
const conventionalParserOptsModule = await import(conventionalParserOptsPath);
const conventionalParserOpts = (await conventionalParserOptsModule.default()).parser;

export default {
  ...conventionalConfig,
  parserPreset: {
    parserOpts: {
      ...conventionalParserOpts,
      issuePrefixes: ['TNO-'],
    },
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants