Skip to content

Commit 8dbed4f

Browse files
authored
Introduce "preset" config (#3)
1 parent 3c3a381 commit 8dbed4f

28 files changed

+373
-40
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ plugin "terraform" {
3232
}
3333
```
3434

35+
For more configuration about the plugin, see [Plugin Configuration](docs/configuration.md).
36+
3537
## Rules
3638

3739
See [Rules](docs/rules/README.md).

docs/configuration.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Configuration
2+
3+
This plugin can take advantage of additional features by configuring the plugin block. Currently, this configuration is only available for preset.
4+
5+
Here's an example:
6+
7+
```hcl
8+
plugin "terraform" {
9+
// Plugin common attributes
10+
11+
preset = "recommended"
12+
}
13+
```
14+
15+
## `preset`
16+
17+
Default: `all` (`recommended` for the bundled plugin)
18+
19+
Enable multiple rules at once. Please see [Rules](rules/README.md) for details. Possible values are `recommended` and `all`.
20+
21+
When using the bundled plugin built into TFLint, you can use this plugin without declaring a "plugin" block. In this case the default is `recommeneded`.

docs/rules/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Rules
22

3-
Terraform language rules implement recommendations from the [Terraform language documentation](https://www.terraform.io/language). If you want to enforce additional usage and style conventions in your configuration, you can author your own ruleset plugin.
3+
Terraform Language rules implement recommendations from the [Terraform Language documentation](https://www.terraform.io/language).
44

5-
Below is a list of available rules.
5+
All rules are enabled by default, but by setting `preset = "recommended"`, you can enable only the rules marked "Recommended" among the following rules. See [Configuration](../configuration.md) for details.
66

7-
|Rule|Description|Enabled|
7+
|Rule|Description|Recommended|
88
| --- | --- | --- |
99
|[terraform_comment_syntax](terraform_comment_syntax.md)|Disallow `//` comments in favor of `#`||
10-
|[terraform_deprecated_index](terraform_deprecated_index.md)|Disallow legacy dot index syntax||
10+
|[terraform_deprecated_index](terraform_deprecated_index.md)|Disallow legacy dot index syntax||
1111
|[terraform_deprecated_interpolation](terraform_deprecated_interpolation.md)|Disallow deprecated (0.11-style) interpolation||
1212
|[terraform_documented_outputs](terraform_documented_outputs.md)|Disallow `output` declarations without description||
1313
|[terraform_documented_variables](terraform_documented_variables.md)|Disallow `variable` declarations without description||
14-
|[terraform_empty_list_equality](terraform_empty_list_equality.md)|Disallow comparisons with `[]` when checking if a collection is empty||
14+
|[terraform_empty_list_equality](terraform_empty_list_equality.md)|Disallow comparisons with `[]` when checking if a collection is empty||
1515
|[terraform_module_pinned_source](terraform_module_pinned_source.md)|Disallow specifying a git or mercurial repository as a module source without pinning to a version||
1616
|[terraform_module_version](terraform_module_version.md)|Checks that Terraform modules sourced from a registry specify a version||
1717
|[terraform_naming_convention](terraform_naming_convention.md)|Enforces naming conventions for resources, data sources, etc||
18-
|[terraform_required_providers](terraform_required_providers.md)|Require that all providers have version constraints through required_providers||
19-
|[terraform_required_version](terraform_required_version.md)|Disallow `terraform` declarations without require_version||
18+
|[terraform_required_providers](terraform_required_providers.md)|Require that all providers have version constraints through required_providers||
19+
|[terraform_required_version](terraform_required_version.md)|Disallow `terraform` declarations without require_version||
2020
|[terraform_standard_module_structure](terraform_standard_module_structure.md)|Ensure that a module complies with the Terraform Standard Module Structure||
21-
|[terraform_typed_variables](terraform_typed_variables.md)|Disallow `variable` declarations without type||
22-
|[terraform_unused_declarations](terraform_unused_declarations.md)|Disallow variables, data sources, and locals that are declared but never used||
21+
|[terraform_typed_variables](terraform_typed_variables.md)|Disallow `variable` declarations without type||
22+
|[terraform_unused_declarations](terraform_unused_declarations.md)|Disallow variables, data sources, and locals that are declared but never used||
2323
|[terraform_unused_required_providers](terraform_unused_required_providers.md)|Check that all `required_providers` are used in the module||
2424
|[terraform_workspace_remote](terraform_workspace_remote.md)|`terraform.workspace` should not be used with a "remote" backend with remote execution||

docs/rules/terraform_deprecated_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Disallow legacy dot index syntax.
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Example
68

79
```hcl

docs/rules/terraform_deprecated_interpolation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Disallow deprecated (0.11-style) interpolation
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Example
68

79
```hcl

docs/rules/terraform_empty_list_equality.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Disallow comparisons with `[]` when checking if a collection is empty.
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Example
68

79
```hcl

docs/rules/terraform_module_pinned_source.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Disallow specifying a git or mercurial repository as a module source without pinning to a version.
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Configuration
68

79
Name | Default | Value

docs/rules/terraform_module_version.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Ensure that all modules sourced from a [Terraform Registry](https://www.terraform.io/docs/language/modules/sources.html#terraform-registry) specify a `version`.
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Configuration
68

79
Name | Description | Default | Type

docs/rules/terraform_required_providers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Require that all providers have version constraints through `required_providers`.
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Configuration
68

79
```hcl

docs/rules/terraform_required_version.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Disallow `terraform` declarations without `required_version`.
44

5+
> This rule is enabled by "recommended" preset.
6+
57
## Configuration
68

79
```hcl

0 commit comments

Comments
 (0)