Skip to content

Support Infix Numerals in case restriction #844

@thomasmost

Description

@thomasmost

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
  • 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
'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

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