Code fix or linter rule to suggest usage or refinement of custom types
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
I like code fixes as a way of gently introducing new language features to users. Custom types feels like potentially a good fit for this.
1. Given the following:
```bicep
param foo object
output bar string = foo.myString
output baz array = foo.myArray
```
We could potentially suggest the following optional codefix:
```bicep
param foo { myString string, myArray array }
```
1. We could also potentially help refine to a more accurate type:
```bicep
param foo { myString string, myArray array }
output baz string[] = foo.myArray
```
Optional codefix:
```bicep
// myString isn't used, so remove it
// myArray can have a more specific type
param foo { myArray string[] }
```
1. A more real-world example:
```bicep
param raProps object
resource rd 'Microsoft.Authorization/roleDefinitions@2022-05-01-preview' existing = {
scope: subscription()
name: raProps.roleDefinitionId
}
resource ra 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
name: guid(raProps.roleDefinitionId, raProps.principalId, kv.id)
scope: kv
properties: {
roleDefinitionId: rd.id
principalId: raProps.principalId
principalType: 'ServicePrincipal'
}
}
```
Could be replaced with:
```bicep
param raProps { roleDefinitionId: string, principalId: string }
resource rd 'Microsoft.Authorization/roleDefinitions@2022-05-01-preview' existing = {
scope: subscription()
name: raProps.roleDefinitionId
}
resource ra 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
name: guid(raProps.roleDefinitionId, raProps.principalId, kv.id)
scope: kv
properties: {
roleDefinitionId: rd.id
principalId: raProps.principalId
principalType: 'ServicePrincipal'
}
}
```
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by reviewing the three examples and locating the compiler or linter codefix entry points that handle custom types. Done should include a scoped decision on which suggestions are supported, with tests covering the proposed transformations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100