question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Proposal] additional features for type-enum scope-enum

See original GitHub issue

Proposal

Hello! I was recently working with commitlint and noticed that “scope-enum” did not offer everything I would have liked. I made a PoC for the suggestion at https://www.npmjs.com/package/commitlint-scope .

The idea is to essentially allow each type to only allow specific scopes, and each scope to only allow specific values inside the brackets. Allowing each scope to have a blob or path to restrict which files may be commit-ed to the valu inside the brackets.

If this is something your team would be up to supporting natively, I would be more then willing to help where I can to integrate it.

“Addon” commitlint.config.js

module.exports = {
  extends: [ '@commitlint/config-conventional' ],
  scopes: {
    'yarn': { files: [ 'package.json', 'yarn.lock', '.yarnclean' ] },
    'lint': { files: [ '.eslintrc', '.huskyrc.js', '.editorconfig', 'commitlint.config.js' ] },
    'repo': { files: [ '*.md', 'LICENSE', '.gitignore' ] },
    'source': { files: [ 'src/*', 'src/**' ] },
    'engine': { files: [ 'index.js' ] },
    'staged': { files: [ '**', '**/*' ] }
  }
}

“Addon” Behavior

Good Commit

git add package.json
git commit -m "chore(yarn): updating package.json"

⧗   input: chore(yarn): updating package.json
✔   found 0 problems, 0 warnings
    (Need help? -> https://github.com/conventional-changelog/commitlint#what-is-commitlint )

Bad Commit

git add eslintrc package.json
git commit -m "chore(yarn): updating package.json"

⧗   input: chore(yarn): update package.json
✖   file '.eslintrc' was not allowed in selected scope [file-forbidden]
✖   found 1 problems, 0 warnings
    (Need help? -> https://github.com/conventional-changelog/commitlint#what-is-commitlint 

Unconfigured Scope

git add package.json
git commit -m "chore(bla): updating package.json"

⧗   input: chore(bla): update package.json
✖   detected commit scope not found in commitlint.config.js [no-detect]
✖   found 1 problems, 0 warnings
    (Need help? -> https://github.com/conventional-changelog/commitlint#what-is-commitlint )

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Context

I created this PoC to allow more control over the specific components that commitlint will control by allowing globs and paths to be used to restrict which files can be commit-ed in which type and scopes. Executing git diff --name-only --cached will allow you to fetch the current staged list of files to be commit-ed. Which is the main leverage for the PoC to be available.

#395 may be applicable to improving to the request too, allowing dynamic building of the lerna packages

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:7

github_iconTop GitHub Comments

1reaction
xCykrixcommented, Apr 24, 2019

@escapedcat thanks! I wanted a little more fine tuned control and couldn’t find a way to restrict the exact files allowed. I figured an official feature set would be more suitable and used over one that just hooks into the config and API with another CLI program. Would also allow it not to have a duplicate prompt output, so it is all contained in one nice and neat one.

0reactions
xCykrixcommented, Nov 14, 2019

@thangbn I’ve just been getting back into using commit linting on my projects. I’ll end up taking a look at the API for plugins and work from there. When I get started I’ll pass a link regarding the plugin if does not already exist. 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

10.4 — Scoped enumerations (enum classes) - Learn C++
Introduced in C++20, a using enum statement imports all of the enumerators from an enum into the current scope. When used with an...
Read more >
Scoped (class) enums: fundamentals and examples - nextptr
In this article, we would talk about the various features of the scoped enums. We would also contrast those features with the unscoped...
Read more >
P1099R5: Using Enum - open-std.org
We propose the addition of a new using enum statement: using enum IDENTIFIER ; This makes all the enumerators of the enum available...
Read more >
Are there any proposals / ideas for improving enums? - Reddit
Enum classes being classes (user defined constructor, functions, ... operations while preserving scope rules and safety of enum class.
Read more >
61469 – language feature: Support for enum underlying type
Just like some other features (inline functions, const, bool), ability to specify data type for enumeration should be useful, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found