Linter rule idea: Verify <resource>.name etc are being used instead of hard-coded strings or variables.
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 79
Description
E.g. from recent doc discussion, we had this:
```bicep
subnet: {
id: resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet1', 'subnet1')
}
```
But this didn't add the proper dependsOn for "vnet"
Expected: Bicep should instead suggest using vnet.name:
```bicep
id: resourceId('Microsoft.Network/virtualNetworks/subnets', vnet.name, 'subnet1')
```
This rule may be tricky, maybe it could be done with specific scenarios and added to over time. It could either be general, like complaining whenever a string literal (whether sourced from a variable or not) is used in certain functions, or maybe it could be smart enough to match the string 'vnet' to existing resource name values. Will need thought/discussion.
Contributor guide
Research direction
Start with the resourceId examples in the issue and investigate how Bicep currently derives dependsOn relationships from resource names. Resolve whether the rule should target specific scenarios or general string and variable usage, then define the diagnostic behavior and scenarios that count as done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100