Closed Ryanf55 closed 1 year ago
The main problem is that your pre-commit file is incomplete, it looks like this:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.17.0
hooks:
- id: yamllint
args: [-c=/path/to/.yamllint]
but it should look like this
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.17.0
hooks:
- id: yamllint
args: [-c=/path/to/.yamllint]
A couple other things:
pre-commit autoupdate
to update all your hooks to their latest version.args
list set to the default example, which points to a nonexistent file. Unless you have a nonstandard location for the config file, you can just omit that.Your desired config might be
---
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
hooks:
- id: yamllint
also note that the error you shared is exclusively from pre-commit erroring out on parsing the configuration, not from erroring out loading the yamllint hook. pre-commit used to support specifying hooks at the top level, but deprecated that at some point. My older version of pre-commit at least threw a warning, but using your version it just errors out.
[WARNING] normalizing pre-commit configuration to a top-level map. support for top level list will be removed in a future version. run: `pre-commit migrate-config` to automatically fix this.
I think our docs could use an update.
Got it. I upgraded. You can use close this once the docs are updated.
I did try running it, but it's not agreeing with running yamllint
in CLI. Should I file another issue, or am I using it incorrectly? The files are staged.
New pre-commit config:
---
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
hooks:
- id: yamllint
Example file:
a: b
c: d
$ yamllint .
./foo.yaml
1:1 warning missing document start "---" (document-start)
2:5 error no new line character at the end of file (new-line-at-end-of-file)
$ pre-commit run
yamllint.................................................................Passed
@Ryanf55 I can reproduce that issue as well. Can you split this to a new issue though? The initial issue will be resolved by the docs change PR.
Description
I'm trying to use the yamllint pre-commit hook, but the example is invalid.
Versions
pre-commit version: 3.1.1 yamllint version: 1.29.0 Host OS: Ubuntu 20.04
Supporting Data
My pre -commit config file (copied from example here)
Error when running:
Logs
version information
error information