conventional-changelog / conventional-changelog/commitlint

Support Infix Numerals in case restriction

Open
#844 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
18.7k
Forks
970
Avg merge
7h 33m
Merged PRs (30d)
49

Description

## Expected Behavior
It would be nice to be able to configure the case restrictions to allow 'infix numerals'. For example:
` 'type-case': [2, 'always', 'snake-case', 'allow-infix-numerals'],`
so that `oauth2` is considered valid snake_case.

## Current Behavior
Currently, `oauth_2` is considered valid snake_case but `oauth2` is not; in other words, numeral characters are considered 'new words'

## Affected packages
* [ ] cli
* [x] core
* [ ] prompt
* [ ] config-angular

## Possible Solution
I mention this in what I would 'expect' but it would be nice to make this configurable for all case restrictions with an 'allow-infix-numerals' property.

**I would also be happy to contribute/open a PR with this change if someone can point me in the right direction**

## Steps to Reproduce (for bugs)

1. Define any case restriction, say `type-case`
2. Make a commit message with a numeral directly following or embedded with alphabetical letters.
3. The case restriction throws!

commitlint.config.js

```js
'use strict';

const fs = require('fs');
const commitTagsFile = fs.readFileSync('./commit-tags.txt', 'utf8');
const commitTags = commitTagsFile.split('\n');
const AbacusConfig = require('./config');
const features = Object.keys(AbacusConfig.features);
const allTags = commitTags.concat(features);
allTags.forEach((tag) => tag.trim());
const filteredCommitTags = allTags.filter((tag) => tag);
module.exports = {
parserPreset: './commitlint-parser',
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [1, 'always', 255],
'subject-empty': [2, 'never'],
'type-case': [2, 'always', 'snake-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
filteredCommitTags
]
}
};

```

## Context
Seems like `oauth2` is arguably valid snake_case...

## Your Environment
Don't believe this is environment-specific.

| Executable | Version |
| ---: | :--- |
| `commitlint --version` | 8.1.0 |
| `git --version` | 2.17.2 |
| `node --version` | 8.15.1 |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.