How to lint only in a specific directory? #1960
Unanswered
nwalters512
asked this question in
Q&A
Replies: 2 comments 8 replies
-
Thank you for your feedback. |
Beta Was this translation helpful? Give feedback.
7 replies
-
Why is the config file at the root of your repository if all Terraform content is in a specific directory? If you use a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I half-asked this question in #1304 before it was locked. As requested, I'll describe my scenario and what I'd like to be able to do.
I have a monorepo. It contains many things, but the relevant part for
tflint
is that it contains various bits of Terraform configuration exclusively in aterraform
directory in the root of the repository. The actual "workspaces" are at various locations within that directory, e.g.terraform/honeycomb/main.tf
andterraform/aws/prod/main.tf
. I have a.tflint.hcl
file in the root of the repository as well.Currently, I can run
tflint --recursive
, which works well enough. However, as far as I can tell, it's recursing into every directory in the repository, even those that will never contain.tf
files (they're all nested exclusively under theterraform
directory). This makes it run slower than it otherwise could.I can see two ways to solve this:
tflint
to receive a set of directories to run on like Prettier, ESLint, etc:tflint --recursive ./terraform
tflint
to be configured with a set of directories to ignore so that I could ensure it doesn't waste time recursing into irrelevant directories (e.g.node_modules
).It was suggested in #1304 that I could run
tflint --chdir ./terraform --recursive
, which is close to my first solution above. This is currently disallowed, and it fails with the following error message:If this were to be supported, I'm not sure if it'd meet my needs. Specifically, based on my reading of the current documentation,
tflint
wouldn't discover the.tflint.hcl
file at the root of my repository with--chdir
. It's possible that #1929 would help here, though I guess it'd be an implementation choice as to how--chdir
would interact with a new config system.Beta Was this translation helpful? Give feedback.
All reactions