Linter: bool properties/parameters must start with Is/Can/Has
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
Parent: #4442
## Convention
**DO** Start property or parameter names of type `bool` with a verb, like `Is`, `Can`, `Has` prefix.
> Source: [Azure SDK for .NET Mgmt Naming Conventions](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/Mgmt-Naming-Conventions.md)
## Observed today
A scan of `Azure/azure-rest-api-specs` (334 `client.tsp` files, 10,754 csharp-scoped `@@clientName` decorators) shows **576** decorators currently encoding this rule by hand. Examples:
- `tracked` → `IsTracked` (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
- `exclude` → `IsExcluded` (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
- `dynamicFieldSchema` → `HasDynamicFieldSchema` (ai/ContentUnderstanding/client.tsp)
- `omitContent` → `ShouldOmitContent` (ai/ContentUnderstanding/client.tsp)
- `returnDetails` → `ShouldReturnDetails` (ai/ContentUnderstanding/client.tsp)
- `restore` → `IsRestore` (apicenter/ApiCenter.Management/client.tsp)
## Proposed linter
**Detection**
Walk Model properties and Operation parameters whose effective type resolves to `boolean`. Flag when the (csharp-cased) name does not begin with `Is`, `Has`, `Can`, `Should`, `Are`, `Was`, `Will`, `Do`, or `Does` followed by an uppercase letter.
**Auto-fix**
Suggest `@@clientName(, "Is", "csharp")`. Heuristic: choose `Is` by default; `Has` for collections/flags; `Can` for capabilities.
**Scope**
The rule should be csharp-scoped — it only flags violations of the .NET convention, not the underlying TypeSpec name. It should suggest inserting a `@@clientName(..., "csharp")` override when the underlying TypeSpec name is intentional, or renaming the TypeSpec model when the convention applies cross-language.
## Acceptance criteria
- [ ] New lint rule registered in the appropriate ruleset (`@azure-tools/typespec-client-generator-core` or `@azure-tools/typespec-azure-resource-manager`).
- [ ] Doc page under `website/src/content/docs/docs/libraries/.../rules/`.
- [ ] Unit tests covering positive / negative cases and the auto-fix.
- [ ] A `.chronus/changes/` entry.
Contributor guide
Assessment
This issue has not been assessed yet.