Confusing error reports when using it in combination with husky, commitlint and lint-staged
- Dominant language
- No language data
- Stars
- 1.9k
- Forks
- 173
- Avg merge
- 10d 13h
- Merged PRs (30d)
- 1
Description
When using the tool in combination with husky, commitlint and lint-staged I get confusing error reports.
How to reproduce it:
- Create a new Git repository
- Create a new C# project inside that repository, name the solution "TheProject"
- Inside the Git repository run this command
`dotnet format .\TheProject\TheProject.sln`
It should work fine.
- Setup the npm dependencies like so
Setup the package.json file
```sh
npm init -y
```
Setup commitlint and husky as described here
https://commitlint.js.org/#/guides-local-setup?id=guide-local-setup
After that setup lint-staged as described here
https://github.com/okonet/lint-staged#installation-and-setup
Your package.json should be simliar to this
```json
{
"lint-staged": {
"*.cs": "dotnet format ./TheProject/TheProject.sln"
},
"devDependencies": {
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"husky": "^6.0.0",
"lint-staged": "^10.5.4"
},
"scripts": {
"prepare": "husky install"
}
}
```
- Modify any .cs file in the project by adding empty lines and random tabs and try to commit
You should see this output
```
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
[STARTED] Preparing...
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for *.cs
[STARTED] dotnet format ./TheProject/TheProject.sln
[FAILED] dotnet format ./TheProject/TheProject.sln [FAILED]
[FAILED] dotnet format ./TheProject/TheProject.sln [FAILED]
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[SUCCESS] Reverting to original state because of errors...
[STARTED] Cleaning up...
[SUCCESS] Cleaning up...
✖ dotnet format ./TheProject/TheProject.sln:
Unrecognized command or argument '/home/.../my-repository/TheProject/Assembly1/MyFile.cs'
dotnet-format
dotnet-format
Usage:
dotnet-format [options] []
Arguments:
A path to a solution file, a project file, or a folder containing a solution or project file. If a path is not specified then the current directory is used. [default: ]
Options:
--no-restore Doesn't execute an implicit restore before formatting.
-f, --folder Whether to treat the `` argument as a simple folder of files.
-w, --fix-whitespace Run whitespace formatting. Run by default when not applying fixes.
-s, --fix-style Run code style analyzers and apply fixes.
-a, --fix-analyzers Run 3rd party analyzers and apply fixes.
--diagnostics A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues. [default: ]
--include A list of relative file or folder paths to include in formatting. All files are formatted if empty. [default: ]
--exclude A list of relative file or folder paths to exclude from formatting. [default: ]
--check Formats files without saving changes to disk. Terminates with a non-zero exit code if any files were formatted.
--report Accepts a file path, which if provided, will produce a json report in the given directory.
-v, --verbosity Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
--binarylog Log all project or solution load information to a binary log file.
--version Show version information
-?, -h, --help Show help and usage information
husky - pre-commit hook exited with code 1 (error)
```
There are two questions coming to my mind
- Why does it say "Unrecognized command or argument" to empty lines with multiple tabs?
- Why is the help section showing up?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.