You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change adds support for JSON-formatted TFLint configuration files
(.tflint.json) in addition to the existing HCL format (.tflint.hcl).
Changes:
- Update config loading to detect file extension and parse JSON/HCL accordingly
- Add support for .tflint.json in default file discovery
- Maintain HCL preference over JSON files
- Add comprehensive unit tests for JSON config loading scenarios
- Add integration tests for JSON config functionality and precedence
- Update user guide documentation with JSON format examples
The implementation uses the existing hclparse.ParseJSON() from the HCL
library, following the same JSON structure conventions as Terraform's
.tf.json files. All existing functionality remains unchanged.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: docs/user-guide/config.md
+42-3Lines changed: 42 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,12 @@ You can change the behavior not only in CLI flags but also in config files. TFLi
4
4
5
5
1. File passed by the `--config` option
6
6
2. File set by the `TFLINT_CONFIG_FILE` environment variable
7
-
3. Current directory (`./.tflint.hcl`)
8
-
4. Home directory (`~/.tflint.hcl`)
7
+
3. Current directory `./.tflint.hcl`
8
+
4. Current directory `./.tflint.json`
9
+
5. Home directory `~/.tflint.hcl`
10
+
6. Home directory `~/.tflint.json`
9
11
10
-
The config file is written in [HCL](https://github.com/hashicorp/hcl). An example is shown below:
12
+
The config file can be written in either [HCL](https://github.com/hashicorp/hcl) or JSON format, determined by the file extension. JSON files use the [HCL-compatible JSON syntax](https://developer.hashicorp.com/terraform/language/syntax/json), following the same structure as Terraform's `.tf.json` files. An HCL example is shown below:
The file path is resolved relative to the module directory when `--chdir` or `--recursive` is used. To use a config file from the working directory when recursing, pass an absolute path:
0 commit comments