ResourceModules icon indicating copy to clipboard operation
ResourceModules copied to clipboard

[Feature Request]: Handle new Bicep linter warning `prefer-unquoted-property-names`

Open AlexanderSehr opened this issue 3 years ago • 6 comments

Description

Recently, a new Bicep linter warning prefer-unquoted-property-names was introduced which leads to a large amount of warnings regarding our modules.

The primary reason are our nested RBAC modules (nested_roleAssignments.bicep) as they contain a map of RoleName - RoleID mappings, and the RoleName is always formatted as a string.

image

This was originally done to make the list easy to read (i.e., consistent formatting), but we may want to revisit that decision now.

For the time being, with PR #1632, the warning is disabled. If we want to enable it again, we should make sure all our modules align with the new rule.

cc: @itpropro

AlexanderSehr avatar Jul 12 '22 20:07 AlexanderSehr

Team decided not to follow the linter recommendation. To still not be bothered by this warning, a bicep config file needs to be set up. TODO: This should also be mentioned in the "known issues".

rahalan avatar Aug 18 '22 15:08 rahalan

Team decided not to follow the linter recommendation. To still not be bothered by this warning, a bicep config file needs to be set up. TODO: This should also be mentioned in the "known issues".

Hi @rahalan, thanks for the update, can you please add the reasoning for deviating from the official bicep team recommendations here? Declaring separate linter configurations in this repository makes it more difficult for customers to integrate the CARML library, as they normally have their own linter configurations already and from my experienced with bicep projects, the prefer-unquoted-property-names is used for internal linting a lot. So an official reasoning, why they have to configure the bicep linting in another way than recommended by the bicep team is necessary to be able to integrate CARML modules in the future.

itpropro avatar Sep 08 '22 18:09 itpropro

Hey @itpropro, even though I'd support the motion, a quorum decided to leave it as is for because a mix of quoted and unquoted strings in the list appears to confuse more than it helps & the generating utility would need to be updated too.

In the bicepconfig.json it says

{
    "analyzers": {
        "core": {
            "rules": {
                (..)
                "prefer-unquoted-property-names": {
                    "level": "off" // Reason: This complains primarily about RBAC roles which are all in quotes to be consistent within the list of roles with and without spaces in their name
                }
            }
        }
    }
}

However, @eriqua provided the alternative suggestion to a ignore rules in the RBAC files instead. This would mean 4/5 lines per file, but we could keep the linter rule for everyhing else active - as it is a good rule.

AlexanderSehr avatar Sep 30 '22 18:09 AlexanderSehr

Attached a Draft PR for reference

AlexanderSehr avatar Sep 30 '22 19:09 AlexanderSehr

Hey @itpropro, even though I'd support the motion, a quorum decided to leave it as is for because a mix of quoted and unquoted strings in the list appears to confuse more than it helps & the generating utility would need to be updated too.

In the bicepconfig.json it says

{
    "analyzers": {
        "core": {
            "rules": {
                (..)
                "prefer-unquoted-property-names": {
                    "level": "off" // Reason: This complains primarily about RBAC roles which are all in quotes to be consistent within the list of roles with and without spaces in their name
                }
            }
        }
    }
}

However, @eriqua provided the alternative suggestion to a ignore rules in the RBAC files instead. This would mean 4/5 lines per file, but we could keep the linter rule for everyhing else active - as it is a good rule.

I think the suggestion from @eriqua for a ignore rules in the RBAC files is a good compromise. This way, customers are still able to use their own linter rules and can keep their linter configs intact without getting warnings thrown.

itpropro avatar Oct 03 '22 15:10 itpropro

Team decides to go with the rule and remove quotes on single strings. Team decides to go for having all roles in alphabetical order, regardless which one has quotes, see https://github.com/Azure/ResourceModules/pull/2200/files

rahalan avatar Oct 13 '22 15:10 rahalan