Skip to content

Add arm-no-replace-inherited-props linting rule#4384

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-arm-no-replace-inherited-props-linting-rule
Draft

Add arm-no-replace-inherited-props linting rule#4384
Copilot wants to merge 2 commits intomainfrom
copilot/add-arm-no-replace-inherited-props-linting-rule

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

Redefining a property already declared on a base model is an Azure API anti-pattern and currently crashes the breaking-change tool (see azure-rest-api-specs#42903). This PR adds a new ARM linter rule to flag the pattern at design time.

Changes

  • New rule arm-no-replace-inherited-props (packages/typespec-azure-resource-manager/src/rules/arm-no-replace-inherited-props.ts)
    • Walks baseModel chain; emits a warning for any property in the current model whose name also appears in any ancestor.
    • Exemptions: the name property of an ARM resource, and any property whose name matches a discriminator declared via @discriminator on an ancestor.
    • Diagnostic message: The property '${propertyName}' is also defined in the base model. Redefining inherited properties can cause problems with OpenAPI tooling and some language representations of the models.
  • Registration in src/linter.ts (included in the all ruleset).
  • Tests covering: clean inheritance, direct override, transitive ancestor override, ARM name exemption, discriminator exemption, and that non-discriminator properties under a @discriminator base are still reported.
  • Docs: new rule page plus regenerated linter.md reference and package README.md.
  • Changeset under .chronus/changes/.

Example

@armProviderNamespace
namespace MyService;

@discriminator("kind")
model Pet {
  kind: string;
  weight: int32;
}

model Cat extends Pet {
  kind: "cat";    // OK — discriminator
  weight: int32;  // ⚠ arm-no-replace-inherited-props
}

@microsoft-github-policy-service microsoft-github-policy-service Bot added lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library meta:website TypeSpec.io updates labels May 6, 2026
Copilot AI changed the title [WIP] Add ARM linting rule to prevent repeating inherited properties Add arm-no-replace-inherited-props linting rule May 6, 2026
Copilot AI requested a review from markcowl May 6, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[linting-rules]: Disallow repeating inherited properties in child types

2 participants