1

git commit -m "feat: testing the commitlint library" @commitlint/cli@16.2.3 - Lint your commit messages

[input] reads from stdin if --edit, --env, --from and --to are omitted

Options:
  -c, --color          toggle colored output           [boolean] [default: true]
  -g, --config         path to the config file                          [string]
      --print-config   print resolved config          [boolean] [default: false]
  -d, --cwd            directory to execute in
                                         [string] [default: (Working Directory)]
  -e, --edit           read last commit message from the specified file or      
                       fallbacks to ./.git/COMMIT_EDITMSG               [string]
  -E, --env            check message in the file at path given by environment   
                       variable value                                   [string]
  -x, --extends        array of shareable configurations to extend       [array]
  -H, --help-url       help url in error message                        [string]
  -f, --from           lower end of the commit range to lint; applies if        
                       edit=false                                       [string]
  -o, --format         output format of the results                     [string]
  -p, --parser-preset  configuration preset to use for
                       conventional-commits-parser                      [string]
  -q, --quiet          toggle console output          [boolean] [default: false]
  -t, --to             upper end of the commit range to lint; applies if
                       edit=false                                       [string]
  -V, --verbose        enable verbose output for reports without problems
                                                                       [boolean]
  -v, --version        display version information                     [boolean]
  -h, --help           Show help                                       [boolean]

Unknown argument: edit
husky - commit-msg hook exited with code 1 (error)

torek
  • 448,244
  • 59
  • 642
  • 775

2 Answers2

10

for Windows OS I later solve the problem by going to my .husky folder and edit npx --no -- commitlint edit to npm commitlint --edit

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

npx --no -- commitlint edit 

to

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

npx commitlint --edit 

  • 1
    Had the same Problem on MacOS but this solution worked. – jzilg May 13 '22 at 10:11
  • I did it and it worked in Ubuntu too. Any idea on WHY this solution works? – Allan May 31 '22 at 01:58
  • I get the feeling the commitlint readme may be stale or has a typo. This solution worked for me too on MacOS. Originally I followed the README which failed. – Ali Jun 30 '22 at 07:52
  • I am unsure, as I did not test it, but from the docs `--no` was previously `--no-install`, which I assume is for use with `npm` and not `npx`. So that may be why... I'll assume that flag/option is not needed for `npx` executable. https://docs.npmjs.com/cli/v8/commands/npx#compatibility-with-older-npx-versions – dvlden Jul 27 '22 at 10:31
  • I added a line to the `"scripts"` entry in my package.json file reading `"prepare-commit-msg": "commitlint --edit"` and then set my husky `prepare-commit-msg` script to include `npm run prepare-commit-msg`. Now it works for me with GitHub Desktop on Windows. – Dr. Derek Austin Sep 07 '22 at 20:22
0

Here is my solution:

  1. open the command line,
  2. in the root directory of the project.
cd .husky
echo "Some commit message" | npx commitlint

if no message echo, it means successful. else failure.

if successful, please try again commit with the message you just typed, and it will pass.

Zevi L.
  • 131
  • 2
  • 4