terraform-linters / tflint

A Pluggable Terraform Linter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TFLint should error when `--config .tflint.hcl` does not exist

bendrucker opened this issue · comments

Introduction

Currently, TFLint treats .tflint.hcl as a special case for --config. It's the default, and even when the referenced file does not exist TFLint ignores that. This can cause confusion for users who think they are specifying config but actually have no .tflint.hcl file in their module, particularly when combined with --recursive or --chdir. The docs are already pretty clear about how configuration files are resolved but users often don't read or understand this caveat.

Proposal

The default value of --config should be empty. TFLint can continue to automatically attempt to auto-load .tflint.hcl if no explicit configuration path is provided. But when --config .tflint.hcl is explicitly passed, TFLint should exit with an error if the file does not exist in the module directory.

While this change could break users relying on that config being ignored in certain modules, those users should be omitting --config entirely if they truly want automatic and optional config loading in each module. Otherwise, this change only "breaks" in the sense that it correct a past divergence between intended and actual configuration.

References

This may be better categorized as a bug.