Skip to content

Linter: bool properties/parameters must start with Is/Can/Has #4443

@haiyuazhang

Description

@haiyuazhang

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

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:

  • trackedIsTracked (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • excludeIsExcluded (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • dynamicFieldSchemaHasDynamicFieldSchema (ai/ContentUnderstanding/client.tsp)
  • omitContentShouldOmitContent (ai/ContentUnderstanding/client.tsp)
  • returnDetailsShouldReturnDetails (ai/ContentUnderstanding/client.tsp)
  • restoreIsRestore (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(<target>, "Is<PascalName>", "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.

Metadata

Metadata

Labels

featureNew feature or requestlib:tcgcIssues for @azure-tools/typespec-client-generator-core library

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions