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

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

Closed
bendrucker opened this issue Nov 28, 2023 · 2 comments · Fixed by #1940
Closed

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

bendrucker opened this issue Nov 28, 2023 · 2 comments · Fixed by #1940
Labels

Comments

@bendrucker
Copy link
Member

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

@wata727
Copy link
Member

wata727 commented Dec 2, 2023

This may be better categorized as a bug.

@max-rocket-internet
Copy link

Could we reopen this?

This can cause confusion for users

Exactly. I just wasted 30 mins on this trying to work out why my rules were not being followed! I almost gave up but decided to Google it and then found this discussion which linked here. I know there's some related technical discussion in #1929 but most users, like myself, expect have a quick read of the --help output and for it to function like other tools. And I would say this should work:

tflint --config=.tflint.hcl --recursive

@terraform-linters terraform-linters locked as resolved and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants