Azure / Azure/typespec-azure

Linter: `Resource` suffix handling — drop or rename to `Data`/`Info`

Open
#4,451 1 comment 0 reactions 0 assignees View on GitHub
feature lib:tcgc linter
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

Parent: #4442

## Convention

For a resource type, drop `Resource` if the remaining noun is descriptive enough; otherwise keep it (e.g., `GenericResource`). For model names that inherit from `ResourceData`/`TrackedResourceData`, append `Data`; otherwise append `Info` if dropping `Resource` makes the name no longer descriptive.

> 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 **204** decorators currently encoding this rule by hand. Examples:

- `TriageResource` → `AdvisorTriageResourceData` (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
- `TriageResource` → `AdvisorTriage` (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
- `AgriServiceResource` → `AgricultureService` (agricultureplatform/AgriculturePlatform.Management/client.tsp)
- `EvidenceResource` → `AppComplianceReportEvidence` (appcomplianceautomation/AppComplianceAutomation.Management/client.tsp)
- `ReportResource` → `AppComplianceReport` (appcomplianceautomation/AppComplianceAutomation.Management/client.tsp)
- `ScopingConfigurationResource` → `AppComplianceReportScopingConfiguration` (appcomplianceautomation/AppComplianceAutomation.Management/client.tsp)

## Proposed linter

**Detection**

Flag ARM resource types whose name ends with `Resource` where:
- The base name (minus `Resource`) is multi-syllable/descriptive → suggest drop.
- Otherwise → suggest `Data` (if derives from `ResourceData`/`TrackedResourceData`) or `Info`.

**Auto-fix**

Insert `@@clientName(, "", "csharp")` with the appropriate variant.

**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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.