Coder Social home page Coder Social logo

git-commit-msg-linter's Introduction

git-commit-msg-linter 👋

npm version npm downloads prerequisite node version visitor count

A lightweight, independent, 0 configurations and joyful git commit message linter.

👀 Watching your every git commit message INSTANTLY 🚀.

git-commit-msg-linter-demo

`gcam` is just an alias to `git commit -a -m`

A git "commit-msg" hook for linting your git commit message against the popular Angular Commit Message Guidelines. As a hook it will run at every commiting to make sure that the message to commit is valid against the conventions. If not the commit will be aborted.

Heavily inspired by pre-commit. Thanks.

简体中文

Table of Contents

Install

npm install git-commit-msg-linter --save-dev

Just install NO CONFIGURATIONS REQUIRED! and your commit message is under linting from now on 🎉. Now go to your codebase to commit a message.

💡 Tips: for husky 5 see Work With Husky 5.

Recommended Commit Message Format

<type>(<scope>): <short summary>
  │       │             │
  │       │             └─⫸ Summary in present tense. Not capitalized. No period at the end.
  │       │
  │       └─⫸ Commit Scope: Optional, can be anything specifying the scope of the commit change.
  |                          For example $location|$browser|$compile|$rootScope|ngHref|ngClick|ngView, etc.
  |                          In App Development, scope can be a page, a module or a component.
  │
  └─⫸ Commit Type: feat|fix|docs|style|refactor|test|chore|perf|ci|build|temp

The <type> and <summary> fields are mandatory, the (<scope>) field is optional.

Bad:

Correct spelling of CHANGELOG.

Good:

docs: correct spelling of CHANGELOG

Good (commit message with scope):

docs(CHANGELOG): correct spelling

The default commit types can be extended or modified by commitlinterrc.json.

Zero Configurations

Configurations Not Required! If it has to be customized we have the guide below.

The default types includes feat, fix, docs, style, refactor, test, chore, perf, ci, build and temp.

The default max-len is 100 which means the commit message cannot be longer than 100 characters. All the settings can be modified in commitlinterrc.json.

commitlinterrc.json

More advanced settings

Except for default types, you can add, overwrite or forbid certain types and so does the max-len.

For example if you have this commitlinterrc.json file below in the root directory of your project:

{
  "types": {
    "feat": "ユーザーが知覚できる新機能",
    "build": "ビルドシステムまたは外部の依存関係に影響する変更(スコープの例:gulp、broccoli、npm)",
    "deps": "依存関係を追加、アップグレード、削除",
    "temp": false,
    "chore": false
  },
  "max-len": 80,
  "debug": true
}

Which means:

  • Modify existing type feat's description to "ユーザーが知覚できる新機能".
  • Add two new types: build and deps.
  • temp is not allowed.
  • chore is forbidden as build covers the same scope.
  • Maximum length of a commit message is adjusted to 80.
  • Display verbose information about the commit message.

A more detailed commitlinterrc.json

{
  "lang": "en-US", // or "zh-CN". Set linter prompt's language
  "types": {
    "feat": "ユーザーが知覚できる新機能",
    "build": "ビルドシステムまたは外部の依存関係に影響する変更(スコープの例:gulp、broccoli、npm)",
    "deps": "依存関係を追加、アップグレード、削除",
    "docs": "ドキュメントのみ変更",
    "fix": false,
    "style": false,
    "refactor": false,
    "test": false,
    "perf": false,
    "ci": false,
    "temp": false,
    "chore": false
  },
  "min-len": 10,
  "max-len": 80,
  "example": "feat: 新機能",
  "scopeDescriptions": [
    "オプションで、コミット変更の場所を指定するものであれば何でもかまいません。",
    "たとえば、$ location、$ browser、$ compile、$ rootScope、ngHref、ngClick、ngViewなど。",
    "アプリ開発では、スコープはページ、モジュール、またはコンポーネントです。"
  ],
  "validScopes": ["workspace", "package1", "package2", "package3", ...],
  "invalidScopeDescriptions": [
    "`scope`はオプションですが、括弧が存在する場合は空にすることはできません。"
  ],
  "subjectDescriptions": [
    "1行での変更の非常に短い説明。"
  ],
  "invalidSubjectDescriptions": [
    "最初の文字を大文字にしないでください",
    "最後にドット「。」なし"
  ],
  "showInvalidHeader": false,
  "debug": false
}

In this config, the one-line example and scope, subject's description section are modified as what your write in the commitlinterrc.json. And the the invalid header is hidden by set "showInvalidHeader": false

detailed-config-demo

Set Linting Prompter's Language

It will use your system's language as the default language. But two ways are provided also. Priority from high to low.

Set in commitlinterrc.json

{
  "lang": "zh-CN"
}

lang in ["en-US", "zh-CN", "pt-BR", "es-ES"].

Set in bash profiles

echo 'export COMMIT_MSG_LINTER_LANG=zh-CN' >> ~/.zshrc

profiles such as .bash_profile, .zshrc etc.

Features

  1. Visualization, low cost to Learn.
  2. Independent, zero configurations.
  3. Prompt error msg precisely, friendly to commit message format unfamiliar developers.
  4. i18n: en-US, pt-BR (Brazilian Portuguese), zh-CN an es-ES supported and you can add more in How to contribute new language support.
  5. The linter is customizable for your team.
  6. It works with the husky flow.
  7. pnpm supported.
  8. ES6 modules or project with "type: module" in package.json supported.

Why yet a new linter

The answer

Firstly it's very important to follow certain git commit message conventions and we recommend Angular's.

Secondly no simple git commit message hook ever exists right now. To Add, to overwrite or to remove types is not so friendly supported. Why not conventional-changelog/commitlint or husky, read the FAQs.

How it works

The answer

The commit-msg hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer. If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through.

https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

After installed, it will copy the hook {PROJECT_ROOT}/.git/hooks/commit-msg if it exists to {PROJECT_ROOT}/.git/hooks/commit-msg.old then the commit-msg will be overwritten by our linting rules.

To uninstall run the uninstall script instead of removing it manually because only in this way, the old commit-msg hook can be restored, so that your next commit messages will be ignored by the linter.

npm uninstall git-commit-msg-linter --save-dev

Before uninstalling, the commit-msg file will be restored and the commit-msg.old will be removed.

FAQs

1. Why not commitlint

Why not conventional-changelog/commitlint?

  • Configurations are relatively complex.
  • No description for type, unfriendly to commit newbies. Because every time your are wondering which type should I use, you must jump out of you commit context to seek documentation in the wild web.
  • To modify type description is also not supported. Unfriendly to non-english speakers. For example, all my team members are Japanese, isn't it more productive to change all the descriptions to Japanese?
  • To add more types is also impossible. This is unacceptable for project with different types already existed.
2. Work With Husky 5

This linter can work by standalone. But if you have husky 5 installed, because husky 5 will ignore the .git/hooks/commit-msg so a .husky/commit-msg need to be added manually:

npx husky add .husky/commit-msg ".git/hooks/commit-msg \$1"

Show the file content of .husky/commit-msg to make sure it has been added successfully otherwise do it manually.

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

.git/hooks/commit-msg $1

More details at issues 8.

3. git-commit-msg-linter badge
<a href="https://www.npmjs.com/package/git-commit-msg-linter">
  <img src="https://badgen.net/badge/git-commit-msg-linter/3.0.0/yellow" alt="commit msg linted by git-commit-msg-linter" />
</a>

TODO

  • Existing rule can be overwritten and new ones can be added through commitlinterrc.json.
  • englishOnly should be configurable through commitlinterrc.json, default false.
  • max-len should be configurable through commitlinterrc.json, default 100.
  • First letter of subject must be a lowercase one.
  • subject must not end with dot.
  • Empty scope parenthesis not allowed.
  • scope parenthesis must be of English which means full-width ones are not allowed.
  • Keep a space between Chinese and English character.
  • Fix git merge commit not valid.
  • Enable showing verbose information for debugging.
  • Suggest similar but valid type on invalid input using did-you-mean.
  • No backup when commit-msg.old existed.
  • Display commit message on invalid error.
  • i18n.
  • Set lang in zshrc, or commitlinrrc.

Development

Use pnpm.

Publish

npm version patch / minor / major

References

  1. Angular Commit Message Guidelines
  2. Angular.js Git Commit Guidelines
  3. Google AngularJS Git Commit Message Conventions

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

How to add new language support

  1. Add the translation into commit-msg-linter.js.
  2. Modify README.md to add the new language.

You can read this PR feat: add support to spanish (es-ES) #18 as an example.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2019 legend80s.

This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

git-commit-msg-linter's People

Contributors

cejaramillof avatar dependabot[bot] avatar legend80s avatar rpc1910 avatar thiagodp avatar zanminkian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

git-commit-msg-linter's Issues

Order types alphabetical

Change in file commit-msg-linter/commit-msg-linter.js

603    function describeTypes(mergedTypes, suggestedType = '') {
604      const types = Object.keys(mergedTypes);
605      const maxTypeLength = [...types].sort((t1, t2) => t2.length - t1.length)[0].length;

add line 604
change line 605

603    function describeTypes(mergedTypes, suggestedType = '') {
604      const sortObject = o => Object.keys(o).sort().reduce((r, k) => (r[k] = o[k], r), {})
605      const types = Object.keys(sortObject(mergedTypes));
606      const maxTypeLength = [...types].sort((t1, t2) => t2.length - t1.length)[0].length;

field additional information

Hello good job! Thank you for creating this wonderful lint.

You have the possibility to include a field of
additional information in commitlinterrc.json and display along with other information?

It shouldn't be installed globally?

In the docs you say to install using the command:

npm install git-commit-msg-linter --save-dev

But in the docs the command used is gcam "message".

For this command work we shouldn't install it globally?

Unable to install on node 14 and earlier versions

스크린샷 2023-05-04 14 09 06

In JavaScript, the .replaceAll() function is one of the new features in ECMAScript 2021. Node.js also requires Node.js version 15 or later to support this function.

So, if you are using Node.js version 15 or later, you are free to use the .replaceAll() function. However, if you are using Node.js version less than 15, you cannot use this function and should use the replace() method instead.

스크린샷 2023-05-04 14 11 14

commit-msg hook doesn't work if bash not installed at `/bin/bash`

The commit-msg hook assumes that bash is installed at /bin/bash, but that is not the case for all systems (including NixOS, which is what I'm running).

It looks like this was broken in #39, which added the shebang:

#!/bin/bash

I think the correct shebang should be:

#!/usr/bin/env bash

which is more portable and should work on systems where bash is somewhere other than /bin/bash (although I couldn't say if this solution works for all supported systems).

Cannot install with pnpm: sh: .git/hooks/commit-msg: No such file or directory

Description

I can't install commit-msg-linter, all other hooks work fine.

Reproduce

git init

pnpm init
pnpm add -D husky
pnpm add -D git-commit-msg-linter

pnpm exec husky install

git add .
git commit -m "hello"

Result

sh: .git/hooks/commit-msg: No such file or directory
husky - commit-msg hook exited with code 127 (error)
husky - command not found in PATH=/home/zau/.asdf/shims:/home/zau/.asdf/bin:/usr/lib/git-core:/home/zau/.local/share/pnpm:/opt/sonar-scanner/bin:/home/zau/.gem/ruby/3.0.0/bin:/home/zau/.yarn/bin:/home/zau/.config/yarn/global/node_modules/.bin:/home/zau/.pyenv/shims:/home/zau/.pyenv/bin:/usr/share/pyenv/plugins/pyenv-virtualenv/shims:/home/zau/bin:/usr/local/bin:/home/zau/.npm-global/bin:/home/zau/.pyenv/bin:/opt/sonar-scanner/bin:/home/zau/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/zau/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/zau/.local/bin:/home/zau/.local/share/gem/ruby/3.0.0/bin

Specs

Using asdf*

  • git: 2.39.1

  • pnpm: 7.26.3

  • node: 19.6.0

  • package.json

{
  "name": "husky-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "git-commit-msg-linter": "^4.5.0",
    "husky": "^8.0.3"
  }
}

Trying

  • remove node_modules
  • remove .git/hooks

Option for `validScopes`

Description

Great tool! I'm missing an option to define valid scopes, which are then validated on pre-commit.

{
  "scopeDescriptions": [
    "Required, should be the name of the npm package affected.",
    "The following is the list of supported scopes:",
    "workspace, package1, package2, package3"
  ],
  "invalidScopeDescriptions": [
    "`scope` is required and its parenthesis cannot be empty."
  ],
  "scopeRequired": true,
}

How does the linter know, which scopes are valid? workspace, package1, package2, package3

Or am I missing something?

Possible implementation

Add an option validScopes: Array<string> = []

Usage

{
  // ...
  "validScopes": ["workspace", "package1", "package2", "package3"],
  "scopeRequired": true,
}

Validation:

const invalidScope = Array.isArray(validScopes) && validScopes.length > 0 && !validScopes.includes(scope);

custom configuration example key not work

Hey thanks for this great work. I'm totally happy with with your module, but iI found a Bug with my configuration. I couldn't get it to work with a custom example message.

Here is my config:

{
  "lang": "en-US",
  "types": {
    "build": "Changes that affect the build system or external dependencies",
    "ci": "Changes to our CI configuration files and scripts",
    "docs": "Documentation only changes",
    "feat": "A new feature",
    "fix": "A bug fix",
    "perf": "A code change that improves performance",
    "refactor": "A code change that neither fixes a bug nor adds a feature",
    "test": "Adding missing tests or correcting existing tests"
  },
  "min-len": 10,
  "max-len": 80,
  "scopeRequired": false,
  "example": "feat(root): new button component (#1403)",
  "scopeDescriptions": [
    "Add one of these scopes:",
    "   root|storybook|config|helper|mock-api|scripts|stories|types"
  ],
  "validScopes": ["root", "storybook", "config", "helper"],
  "invalidScopeDescriptions": [
    "\n    A scope is required!"
  ],
  "subjectDescriptions": [
    "Write a summary about your work"
  ],
  "invalidSubjectDescriptions": [
    "\n    A summary in present tense, not capitalized and without period at the end, is required!"
  ],
  "showInvalidHeader": false,
  "debug": false
}

I was also actually searching in your code where the problem is and saw that you never set or use the example key from the custom configuration. Can you add something like this to your module?

// commit-msg-linter.js
123
124        if (!validateMessage(msg, {
125          ...rest,
126      
127          mergedTypes,
128          maxLen,
129          minLen,
130          verbose,
131          example: config.example ? config.example : example, <---- here
132          showInvalidHeader,
133          scopeDescriptions,
134          invalidScopeDescriptions,
135          subjectDescriptions,
136          invalidSubjectDescriptions,
137          postSubjectDescriptions,
138      
139          lang,
140          englishOnly,
141          scopeRequired,
142        })) {
143          process.exit(1);
144        } else {
145          process.exit(0);
146        }
147

It is a solution that works, but maybe you know a better way.
thanks, best

Lang config on file commitlinterrc.json not working

I configure the config file to pt-BR but the message continue in english:

my commitlinterrc.json:

{
  "lang": "pt-BR",
  "min-len": 8,
  "max-len": 100,
  "showInvalidHeader": false
}

The output:
image

I think a found the problem.
On the getLanguage function it converts to Lower:

/**
 * @returns {string}
 */
function getLanguage(configLang) {
  const lang =
    configLang ||
    process.env.COMMIT_MSG_LINTER_LANG ||
    Intl.DateTimeFormat().resolvedOptions().locale;

  return lang && lang.toLowerCase();
}

So "pt-BR" ends up as "pt-br"
and it was not found in i18n because i18n["pt-BR"] does not exist
image

Run in command line

Is it possible to run the script for a range of commits from command line?

Something like:

commit-msg-linter sha1 sha2

So it can be ran from CI to make sure every commit message from sha1 and sha2 are valid.

ChainAlert: npm package release (3.3.0) has no matching tag in this repo

Dear git-commit-msg-linter maintainers,
Thank you for your contribution to the open-source community.

This issue was automatically created to inform you a new version (3.3.0) of git-commit-msg-linter was published without a matching tag in this repo.

Our service monitors the open-source ecosystem and informs popular packages' owners in case of potentially harmful activity.
If you find this behavior legitimate, kindly close and ignore this issue. Read more

badge

Update example message for pt-BR

Hello! First of all, thanks for this awesome lint.

I think that the example of a right formatted commit message for pt-BR language is wrong. I am brand new to open source contributing but I am looking forward to providing enough information to solve this problem, or even open the PR to fix the issue.

The thing is if we set the language to pt-BR, if we try to commit with the example provided in the error message, the error still persists due to first letter being capitalized.

For example, if I try to do this

git commit -m "teste"

It gives me this error message with the following:

exemplo: docs: Atualiza o README com link para a nova documentação

If I try to commit with the example (in Portugue "exemplo") message, I still can not commit because the first letter is capitalized.

error: cannot spawn .git/hooks/commit-msg: No such file or directory

I'm getting the following error when trying to commit just after installing git-commit-msg-linter in my project:

error: cannot spawn .git/hooks/commit-msg: No such file or directory

The project is just Vue.js boilerplate created with Vite. You can check it here.

My commit-msg file using the current version of git-commit-msg-linter is the following:

# [email protected] 3/29/2023, 3:54:43 PM
# id=commit-msg-linter - THE id COMMENT SHOULD NOT BE DELETED OR MODIFIED!
# It's used to check whether this commit-msg hook file is created by us,
# if it is then we can remove it confidently on uninstallation.

cat E:\Dev\Treinamentos\my-games-list\.yarn\unplugged\git-commit-msg-linter-npm-4.9.2-060e731a8e\node_modules\git-commit-msg-linter\commit-msg-linter.js | node --input-type=commonjs

I managed to fix this error rolling git-commit-msg-linter back to the version I was using before on my projects (version 4.1.2) which has the following commit-msg file:

#!/bin/bash
#
# Solve the problem of [Wishlist: support for ES6 modules. #14].
# https://github.com/legend80s/commit-msg-linter/issues/14

# This shell script template is from: https://google.github.io/styleguide/shellguide.html

# $0: .git/hooks/commit-msg, $1: .git/COMMIT_EDITMSG, $2: , $3:
# node '.git/hooks/commit-msg-linter.js' $1

# id=commit-msg-linter - The comment SHOULD NOT BE DELETED.

# https://nodejs.org/api/packages.html#--input-type-flag
cat .git/hooks/commit-msg-linter.js | node --input-type=commonjs

OS: Windows 11
Node: v18.15.0
Yarn: 3.5.0 (I have enabled PnP)

ChainAlert: npm package release (3.3.0) has a new "postinstall" script

Dear git-commit-msg-linter maintainers,
Thank you for your contribution to the open-source community.

This issue was automatically created to inform you a new "postinstall" script was added to version 3.3.0 of git-commit-msg-linter.

The "postinstall" script may run automatically upon installing the package.

scripts section from the package.json file:

{
    "pub:patch": "npm version patch",
    "pub:minor": "npm version minor",
    "pub:major": "npm version major",
    "lint": "eslint *.js",
    "lint:fix": "eslint --fix *.js",
    "install": "echo '[git-commit-msg-linter] install start.' && node install.js",
    "postinstall": "echo '[git-commit-msg-linter] postinstall start.' && node install.js",
    "uninstall": "node uninstall.js",
    "preversion": "npm run lint",
    "postversion": "npm publish && git push && git push --tags",
    "test": "echo open \"https://github.com/legend80s/commit-msg-linter-test\" && exit 0"
}

Our service monitors the open-source ecosystem and informs popular packages' owners in case of potentially harmful activity.
If you find this behavior legitimate, kindly close and ignore this issue. Read more

badge

Require scope

Is it possible to require scope? We have a monorepo and we want every message to contain a scope.

E.g. feat(web): new buttons must have (web) in the commit message or it fails!

Add advanced setting keys & colored output

  • advanced setting:
    • englishOnly should check complete language
    • make it adjustable in commitlinterrc.json > First letter of subject must be a lowercase one.
  • color support for windows cmd shell
  • sort type list alphabetical

Docs

I. Currently, I can modify/overwrite the type section and I can define my own.

************* Invalid Git Commit Message **************
commit message: fix: test
correct format: (): => Can I modify commit pattern?
example: docs: update README => This section is hardcoded in hook. Is there any place where I can put README file with my example?

II.
scope:
Optional, can be anything specifying place of the commit change.
For example $location, $browser, $compile, $rootScope, ngHref, ngClick, ngView, etc.
In App Development, scope can be a page, a module or a component.

subject:
A very short description of the change in one line.

Can I change the description in these two sections?

The package is not working with husky v5

The issue #7 was not resolved. I'm trying to use your last solution @legend80s, but I'm receiving the error below:

ℹ No staged files match any configured task.
(node:98010) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
at readFile (fs.js:326:10)
at internal/util.js:297:30
at new Promise ()
at readFile (internal/util.js:296:12)
at main (/Users/viniciuscarvalho/Projects/hub-api/.git/hooks/commit-msg:47:5)
at Object. (/Users/viniciuscarvalho/Projects/hub-api/.git/hooks/commit-msg:56:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
(Use node --trace-warnings ... to show where the warning was created)
(node:98010) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:98010) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[feat/signup 656afe6] asdfsdaf
1 file changed, 6 insertions(+), 6 deletions(-)

Extract the `commit-msg-linter.js` to a sub-library

I have a all-in-one tool (@zanminkian/git-hooks) using this npm package as its dependency to check the commit message. The tool of mine will not install if user don't run git-hooks install. But I cannot control it because git-commit-msg-linter will install automatically, which means it will write the .git/hooks/commit-msg file automatically.

I want the dependency - git-commit-msg-linter do not setup postinstall script in its package.json. But this is a big breaking change which should not come true. The solution is extracting the commit-msg-linter.js to a single npm library, named commit-msg-linter (or any other name). git-commit-msg-linter uses commit-msg-linter as its dependency.

May be we have to change this git repo to a monorepo.

Wishlist: support for ES6 modules.

Wishlist: support of ES6 modules.

Presently, for projects that have "type: module" in package.json, a commit will fail with the following error:

internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /home/kevin/code/ftek/receiver/.git/hooks/commit-msg
at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:71:15)
at Loader.getFormat (internal/modules/esm/loader.js:104:42)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:31)
at async Loader.import (internal/modules/esm/loader.js:176:17)
at async Object.loadESM (internal/process/esm_loader.js:68:5) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

feat: `install.js` support `--silent` option

Run node node_modules/git-commit-msg-linter/install.js will print some logs what I don't need. Support node node_modules/git-commit-msg-linter/install.js --silent to keep quiet.

Error on version >= 4.8.0

After version 4.8.0, when I install the dependency and try do a commit, this error is returned

image

In this test, I've created a simple repository with git and just add git-commit-msg-linter dependency.

Husky 6 configuration

Does it take some additional configuration to work with Husky 6?
Husky is up and running and the commit-msg-linter is installed but it does not run any validations.

My envirioment:
node 15.14.0
git-commit-msg-linter 3.1.0
husky 6.0.0
git version 2.30.2.windows.1

Tks

Suggestion: rename this repo to `git-commit-msg-linter`

Sync with npm. This will help this project easier to understand and easier to spread this project.

After renaming this repo, github will auto redirect to https://github.com/legend80s/git-commit-msg-linter if people visit commit-msg-linter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.