michaellzc / vscode-hadolint

VSCode extension to integrate hadolint, a Dockerfile linter, into VSCode
https://marketplace.visualstudio.com/items?itemName=exiasr.hadolint
MIT License
78 stars 5 forks source link

Use ~/.config/hadolint.yaml config file by default #52

Closed SuperSandro2000 closed 3 years ago

SuperSandro2000 commented 3 years ago

Right now the config file at ~/.config/hadolint.yaml is not used by default and I needed to set:

  "hadolint.cliOptions": [
    "--config ~/.config/hadolint.yaml",
    "--no-color"
  ]

I think this should be the default because the cli tool also defaults to that file.

michaellzc commented 3 years ago

@SuperSandro2000

vscode-hadolint extension relies on invoking the hadolint binary from system path to generate the diagnostics messages without adding any magic.

~/.config/hadolint.yaml is one of the global configuration file paths that hadolint binary can look up automatically without passing the extra flag --config. Therefore, I believe "--config ~/.config/hadolint.yaml" is redundant. Additionally, I don't think ~/.config/hadolint.yaml is cross-platform compatible and there is no single path that works on both Linux and Windows.

Moreover, I just test it out and it works fine in both single root and multi-root project. The warning Always tag the version of an image explicitly no longer shows up.

/some/path/Dockerfile

FROM busy box

~/.config/hadolint.yaml

ignored:
  - DL3006

If somehow hadolint doesn't respect your global configuration at ~/.config/hadolint.yaml, I suggest try either upgrading hadolint binary to the latest release (maybe there's a regression) or try invoking hadolint directly from CLI see if you get a different result than the VS Code extension. If you do get different result, we can take another look into the extension.

SuperSandro2000 commented 3 years ago

After taking a second look at this it actually works and I confused some of the rules I ignore with some actual issues. Sorry for wasting your time with this.