Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yamllint: ignore rule in config file doesn't work #39

Open
uwehdaub opened this issue Nov 27, 2023 · 1 comment
Open

yamllint: ignore rule in config file doesn't work #39

uwehdaub opened this issue Nov 27, 2023 · 1 comment

Comments

@uwehdaub
Copy link

I've created some ignore rule in .yamllint.yaml like the following

rules:
  indentation:
    ignore:
      - "base/templates/deployment.yaml"

When I run yamllint from the command line all works fine.
But in VS-Code I still get a line to long error.

After some experimentation I stumbled about this in .settings

    "yamllint": {
      "capabilities": ["ignore-line"],
      "command": [
        "yamllint",
        "--format",
        "parsable",
        ["$config", "--config-file", "$config"],
        "-"
      ],
...

which means, yamllint reads the file from stdin and obvious has no filename.

I can get around this problem by calling yamllint with the filename

    "yamllint": {
      "capabilities": ["ignore-line"],
      "command": [
        "yamllint",
        "--format",
        "parsable",
        ["$config", "--config-file", "$config"],
        "$file" # <-- change!
      ],
...

but I have to re-write the ignore rules to

rules:
  indentation:
    ignore:
      - "**/base/templates/deployment.yaml"

because it seems, that yamllint is not executed from the root of the workspace.

After these changes my yaml files are linted as they were linted from the command line.

Is there anything that I miss, or is there a better way to tackle this problem?

@konstantin-kornienko
Copy link

Agreed on your findings, @uwehdaub.
Looks like it's better to always spawn the linter process from the current's file directory. Otherwise it breaks the ability of searching linters' config files if parent directories (yamllint in particular).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants