In previous article, we have discussed about bicep configuration file. We have discussed about the module aliases and credentials precedence. In this short article, we are going to understand how the linter rules can be set.
What do we need ?
Obviously we need a bicepconfig.json file. We already have seen how to create one using Visual Studio Code.
Visual Studio code provides intellisense while editing a bicep config file. We already have seen how to create the config file using Visual Studio Code.
Basically, the path at which rule configurations are done is
"analyzers" : "core". There are three properties here:
- enabled, to indicate if Linter is enabled. It is better to set it to true to make sure linter is enabled.
- verbose: specify true to show the bicepconfig.json file used by Visual Studio Code.
- rules, which contains list of rules. Each rule has a property level, indicating what should be done if a violation is found.
The level property of the rule object can have any of the four values mentioned below:
- Error, indicating that the rule violation should be treated as error, and should fail the build. The offending piece of code will have a red squiggle underline and will appear in
- Warning, indicates the rule violation would appear as warning, but it woul not fail the build. The offending piece of code will have a yellow squiggle underline and this will also appear in the
- Info, the rule violation will not appear in command line output. The offending code will have blue squiggle underline and it will also appear in
- Off, would cause the rule to be suppressed completely.
The code snippet given below shows an example bicepconfig.json file, which contain two rules.
- If there are any unused parameters, there will be a warning
- If there are any unused existing resources in bicep file, there would be an error causing build to fail
I hope you find this information helpful. Let me know your thoughts.