codemod/location-parameter-allowedvalues
Read-only audit of deployment templates for location parameters constrained by allowedValues lists.
# @codemod/location-parameter-allowedvalues
Read-only audit of deployment templates for location parameters constrained by `allowedValues` lists.
## What It Reports
- Scans deployment JSON and commented JSON files.
- Reports `allowedValues` on string parameters whose name indicates a deployment location.
- Applies to top-level template parameters and nested deployment templates.
- Leaves other parameters and deployment parameter value files unchanged.
## Usage
```bash
pnpm dlx codemod@latest workflow run -w . -t /path/to/repo
```
This workflow scans `**/*.{json,jsonc}` and uses parser-backed detection to report matching parameter definitions without editing source files.
## Match Rules
- The file must look like a deployment template or parameter document.
- The codemod only inspects objects under a `parameters` property.
- The parameter name must contain `location`.
- The parameter definition must declare `"type": "string"`.
- The parameter definition must contain `allowedValues`.
## Preserve Cases
- Non-location parameters that use `allowedValues`.
- Parameter value files where `parameters.<name>` only contains `value`.
- Location parameters that already omit `allowedValues`.
## Example
Before:
```json
{
"parameters": {
"location": {
"type": "string",
"allowedValues": ["eastus", "westus2"],
"defaultValue": "[resourceGroup().location]"
}
}
}
```
Reported finding:
`location` is constrained by an `allowedValues` list. Remove the list and use a dynamic default such as `resourceGroup().location` or `deployment().location`.
## Metrics
- `location_parameter_allowedvalues_files`
- `location_parameter_allowedvalues_findings`
- `location_parameters_scanned`
## Development
```bash
# Test the fixtures
pnpm test
# Validate the workflow
pnpm dlx codemod@latest workflow validate -w workflow.yaml
# Type-check the codemod
pnpm check-types
```
## License
MIT