diff --git a/.chronus/changes/disable-old-arm-linting-rules-2026-6-30-2-42-0.md b/.chronus/changes/disable-old-arm-linting-rules-2026-6-30-2-42-0.md new file mode 100644 index 0000000000..b86b6d77a6 --- /dev/null +++ b/.chronus/changes/disable-old-arm-linting-rules-2026-6-30-2-42-0.md @@ -0,0 +1,8 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-azure-rulesets" + - "@azure-tools/typespec-azure-resource-manager" +--- + +Removed `missing-x-ms-identifiers` and `arm-resource-interface-requires-decorator` linter rules as they are no longer applicable. diff --git a/packages/samples/specs/resource-manager/legacy/static-routes/main.tsp b/packages/samples/specs/resource-manager/legacy/static-routes/main.tsp index 1ee47938c4..7ddb0a1507 100644 --- a/packages/samples/specs/resource-manager/legacy/static-routes/main.tsp +++ b/packages/samples/specs/resource-manager/legacy/static-routes/main.tsp @@ -74,7 +74,6 @@ union ProvisioningState { Deleting: "Deleting", } -#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" interface EmplOps extends Azure.ResourceManager.Legacy.RoutedOperations< BaseParams & { @@ -96,7 +95,6 @@ alias BaseParams = { ...SubscriptionIdParameter; }; -#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" interface EmplOps2 extends Azure.ResourceManager.Legacy.RoutedOperations< BaseParams2 & { diff --git a/packages/samples/specs/resource-manager/resource-types/specific-extension/main.tsp b/packages/samples/specs/resource-manager/resource-types/specific-extension/main.tsp index 67da5feed8..eb3120eb47 100644 --- a/packages/samples/specs/resource-manager/resource-types/specific-extension/main.tsp +++ b/packages/samples/specs/resource-manager/resource-types/specific-extension/main.tsp @@ -219,7 +219,6 @@ alias ParentParameters = { ...ParentKeysOf; }; -#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" interface GenericOps extends Azure.ResourceManager.Legacy.ExtensionOperations< GenericResourceParameters, diff --git a/packages/typespec-azure-resource-manager/README.md b/packages/typespec-azure-resource-manager/README.md index b30aab75ae..7e36941d3a 100644 --- a/packages/typespec-azure-resource-manager/README.md +++ b/packages/typespec-azure-resource-manager/README.md @@ -26,47 +26,45 @@ Available ruleSets: ## Rules -| Name | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-child-resources`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-agent-base-type-child-resources) | Resources decorated with @azureBaseType for the Agent base type must have both a Conversation and a Response child resource. | -| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-lifecycle-operations`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-agent-base-type-lifecycle-operations) | Conversation and Response child resources of an Agent must define create, read, update, and delete lifecycle operations. | -| [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-record) | Don't use Record types for ARM resources. | -| [`@azure-tools/typespec-azure-resource-manager/arm-no-path-casing-conflicts`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-path-casing-conflicts) | Operation paths must be unique when compared case-insensitively. | -| [`@azure-tools/typespec-azure-resource-manager/no-override-props`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-override-props) | Disallow redefining properties already defined in a base type. | -| [`@azure-tools/typespec-azure-resource-manager/arm-common-types-version`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-common-types-version) | Specify the ARM common-types version using @armCommonTypesVersion. | -| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/delete-operation-response-codes) | Ensure delete operations have the appropriate status codes. | -| [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/put-operation-response-codes) | Ensure put operations have the appropriate status codes. | -| [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/post-operation-response-codes) | Ensure post operations have the appropriate status codes. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-action-no-segment) | `@armResourceAction` should not be used with `@segment`. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-duplicate-property) | Warn about duplicate properties in resources. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-invalid-envelope-property) | Check for invalid resource envelope properties. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-invalid-version-format) | Check for valid versions. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-key-invalid-chars) | Arm resource key must contain only alphanumeric characters. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-name-pattern) | The resource name parameter should be defined with a 'pattern' restriction. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-operation-response) | [RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-path-segment-invalid-chars) | Arm resource name must contain only alphanumeric characters. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-provisioning-state) | Check for properly configured provisioningState property. | -| [`@azure-tools/typespec-azure-resource-manager/version-progression`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/version-progression) | Validate that ARM service versions all use unique dates and are declared in strictly increasing chronological order. | -| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-no-key`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-custom-resource-no-key) | Validate that custom resource contains a key property. | -| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-usage-discourage`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-custom-resource-usage-discourage) | Verify the usage of @customAzureResource decorator. | -| [`@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/beyond-nesting-levels) | Tracked Resources must use 3 or fewer levels of nesting. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-operation) | Validate ARM Resource operations. | -| [`@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-resource-delete-operation) | Check for resources that must have a delete operation. | -| [`@azure-tools/typespec-azure-resource-manager/empty-updateable-properties`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/empty-updateable-properties) | Should have updateable properties. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-interface-requires-decorator) | Each resource interface must have an @armResourceOperations decorator. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-invalid-action-verb) | Actions must be HTTP Post or Get operations. | -| [`@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/improper-subscription-list-operation) | Tenant and Extension resources should not define a list by subscription operation. | -| [`@azure-tools/typespec-azure-resource-manager/lro-location-header`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/lro-location-header) | A 202 response should include a Location response header. | -| [`@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers) | Array properties should describe their identifying properties with x-ms-identifiers. Decorate the property with @OpenAPI.extension("x-ms-identifiers", #[id-prop]) where "id-prop" is a list of the names of identifying properties in the item type. | -| [`@azure-tools/typespec-azure-resource-manager/no-response-body`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-response-body) | Check that the body is empty for 202 and 204 responses, and not empty for other success (2xx) responses. | -| [`@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-operations-endpoint) | Check for missing Operations interface. | -| [`@azure-tools/typespec-azure-resource-manager/patch-envelope`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/patch-envelope) | Patch envelope properties should match the resource properties. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-patch`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-patch) | Validate ARM PATCH operations. | -| [`@azure-tools/typespec-azure-resource-manager/resource-name`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-name) | Check the resource name. | -| [`@azure-tools/typespec-azure-resource-manager/retry-after`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/retry-after) | Check if retry-after header appears in response body. | -| [`@azure-tools/typespec-azure-resource-manager/unsupported-type`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/unsupported-type) | Check for unsupported ARM types. | -| [`@azure-tools/typespec-azure-resource-manager/secret-prop`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/secret-prop) | RPC-v1-13: Check that property with names indicating sensitive information(e.g. contains auth, password, token, secret, etc.) are marked with @secret decorator. | -| [`@azure-tools/typespec-azure-resource-manager/no-empty-model`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-empty-model) | ARM Properties with type:object that don't reference a model definition are not allowed. ARM doesn't allow generic type definitions as this leads to bad customer experience. | +| Name | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-child-resources`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-agent-base-type-child-resources) | Resources decorated with @azureBaseType for the Agent base type must have both a Conversation and a Response child resource. | +| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-lifecycle-operations`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-agent-base-type-lifecycle-operations) | Conversation and Response child resources of an Agent must define create, read, update, and delete lifecycle operations. | +| [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-record) | Don't use Record types for ARM resources. | +| [`@azure-tools/typespec-azure-resource-manager/arm-no-path-casing-conflicts`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-path-casing-conflicts) | Operation paths must be unique when compared case-insensitively. | +| [`@azure-tools/typespec-azure-resource-manager/no-override-props`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-override-props) | Disallow redefining properties already defined in a base type. | +| [`@azure-tools/typespec-azure-resource-manager/arm-common-types-version`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-common-types-version) | Specify the ARM common-types version using @armCommonTypesVersion. | +| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/delete-operation-response-codes) | Ensure delete operations have the appropriate status codes. | +| [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/put-operation-response-codes) | Ensure put operations have the appropriate status codes. | +| [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/post-operation-response-codes) | Ensure post operations have the appropriate status codes. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-action-no-segment) | `@armResourceAction` should not be used with `@segment`. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-duplicate-property) | Warn about duplicate properties in resources. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-invalid-envelope-property) | Check for invalid resource envelope properties. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-invalid-version-format) | Check for valid versions. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-key-invalid-chars) | Arm resource key must contain only alphanumeric characters. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-name-pattern) | The resource name parameter should be defined with a 'pattern' restriction. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-operation-response) | [RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-path-segment-invalid-chars) | Arm resource name must contain only alphanumeric characters. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-provisioning-state) | Check for properly configured provisioningState property. | +| [`@azure-tools/typespec-azure-resource-manager/version-progression`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/version-progression) | Validate that ARM service versions all use unique dates and are declared in strictly increasing chronological order. | +| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-no-key`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-custom-resource-no-key) | Validate that custom resource contains a key property. | +| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-usage-discourage`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-custom-resource-usage-discourage) | Verify the usage of @customAzureResource decorator. | +| [`@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/beyond-nesting-levels) | Tracked Resources must use 3 or fewer levels of nesting. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-operation) | Validate ARM Resource operations. | +| [`@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-resource-delete-operation) | Check for resources that must have a delete operation. | +| [`@azure-tools/typespec-azure-resource-manager/empty-updateable-properties`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/empty-updateable-properties) | Should have updateable properties. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-invalid-action-verb) | Actions must be HTTP Post or Get operations. | +| [`@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/improper-subscription-list-operation) | Tenant and Extension resources should not define a list by subscription operation. | +| [`@azure-tools/typespec-azure-resource-manager/lro-location-header`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/lro-location-header) | A 202 response should include a Location response header. | +| [`@azure-tools/typespec-azure-resource-manager/no-response-body`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-response-body) | Check that the body is empty for 202 and 204 responses, and not empty for other success (2xx) responses. | +| [`@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-operations-endpoint) | Check for missing Operations interface. | +| [`@azure-tools/typespec-azure-resource-manager/patch-envelope`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/patch-envelope) | Patch envelope properties should match the resource properties. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-patch`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-patch) | Validate ARM PATCH operations. | +| [`@azure-tools/typespec-azure-resource-manager/resource-name`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-name) | Check the resource name. | +| [`@azure-tools/typespec-azure-resource-manager/retry-after`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/retry-after) | Check if retry-after header appears in response body. | +| [`@azure-tools/typespec-azure-resource-manager/unsupported-type`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/unsupported-type) | Check for unsupported ARM types. | +| [`@azure-tools/typespec-azure-resource-manager/secret-prop`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/secret-prop) | RPC-v1-13: Check that property with names indicating sensitive information(e.g. contains auth, password, token, secret, etc.) are marked with @secret decorator. | +| [`@azure-tools/typespec-azure-resource-manager/no-empty-model`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-empty-model) | ARM Properties with type:object that don't reference a model definition are not allowed. ARM doesn't allow generic type definitions as this leads to bad customer experience. | ## Decorators diff --git a/packages/typespec-azure-resource-manager/src/linter.ts b/packages/typespec-azure-resource-manager/src/linter.ts index a15d99de6b..d35e073caa 100644 --- a/packages/typespec-azure-resource-manager/src/linter.ts +++ b/packages/typespec-azure-resource-manager/src/linter.ts @@ -11,7 +11,6 @@ import { armPostResponseCodesRule } from "./rules/arm-post-response-codes.js"; import { armPutResponseCodesRule } from "./rules/arm-put-response-codes.js"; import { armResourceActionNoSegmentRule } from "./rules/arm-resource-action-no-segment.js"; import { armResourceDuplicatePropertiesRule } from "./rules/arm-resource-duplicate-property.js"; -import { interfacesRule } from "./rules/arm-resource-interfaces.js"; import { armResourceInvalidActionVerbRule } from "./rules/arm-resource-invalid-action-verb.js"; import { armResourceEnvelopeProperties } from "./rules/arm-resource-invalid-envelope-property.js"; import { armResourceInvalidVersionFormatRule } from "./rules/arm-resource-invalid-version-format.js"; @@ -26,7 +25,6 @@ import { coreOperationsRule } from "./rules/core-operations.js"; import { envelopePropertiesRules } from "./rules/envelope-properties.js"; import { improperSubscriptionListOperationRule } from "./rules/improper-subscription-list-operation.js"; import { lroLocationHeaderRule } from "./rules/lro-location-header.js"; -import { missingXmsIdentifiersRule } from "./rules/missing-x-ms-identifiers.js"; import { noEmptyModel } from "./rules/no-empty-model.js"; import { noOverridePropsRule } from "./rules/no-override-props.js"; import { deleteOperationMissingRule } from "./rules/no-resource-delete-operation.js"; @@ -65,11 +63,9 @@ const rules = [ coreOperationsRule, deleteOperationMissingRule, envelopePropertiesRules, - interfacesRule, armResourceInvalidActionVerbRule, improperSubscriptionListOperationRule, lroLocationHeaderRule, - missingXmsIdentifiersRule, noResponseBodyRule, operationsInterfaceMissingRule, patchEnvelopePropertiesRules, diff --git a/packages/typespec-azure-resource-manager/src/rules/arm-resource-interfaces.ts b/packages/typespec-azure-resource-manager/src/rules/arm-resource-interfaces.ts deleted file mode 100644 index d6ac05722b..0000000000 --- a/packages/typespec-azure-resource-manager/src/rules/arm-resource-interfaces.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Interface, createRule } from "@typespec/compiler"; - -import { isArmOperationsListInterface } from "../private.decorators.js"; -import { isInternalTypeSpec } from "./utils.js"; - -export const interfacesRule = createRule({ - name: "arm-resource-interface-requires-decorator", - severity: "warning", - description: "Each resource interface must have an @armResourceOperations decorator.", - url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-interface-requires-decorator", - messages: { - default: "Each resource interface must have an @armResourceOperations decorator.", - }, - create(context) { - return { - interface: (interfaceContext: Interface) => { - if ( - !isInternalTypeSpec(context.program, interfaceContext) && - !isArmOperationsListInterface(context.program, interfaceContext) - ) { - if ( - !interfaceContext.decorators.some( - (d) => - d.decorator.name === "$armResourceOperations" || - d.decorator.name === "$armResourceRoute", - ) - ) { - context.reportDiagnostic({ - target: interfaceContext, - }); - } - } - }, - }; - }, -}); diff --git a/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts b/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts deleted file mode 100644 index 5d60502b02..0000000000 --- a/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { - ArrayModelType, - ModelProperty, - Program, - createAddDecoratorCodeFix, - createRule, - getProperty, - isArrayModelType, - paramMessage, -} from "@typespec/compiler"; -import { isArmCommonType } from "../common-types.js"; -import { getArmIdentifiers, getArmKeyIdentifiers } from "../resource.js"; - -export const missingXmsIdentifiersRule = createRule({ - name: "missing-x-ms-identifiers", - description: `Array properties should describe their identifying properties with x-ms-identifiers. Decorate the property with @OpenAPI.extension("x-ms-identifiers", #[id-prop]) where "id-prop" is a list of the names of identifying properties in the item type.`, - severity: "warning", - url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers", - messages: { - default: `Missing identifying properties of objects in the array item, please add @identifiers(#[""]) to specify it. If there are no appropriate identifying properties, please add @identifiers(#[]).`, - notArray: paramMessage`Value passed to @identifiers(...) was a "${"valueType"}". Pass an array of property name.`, - missingProperty: paramMessage`Property "${"propertyName"}" is not found in "${"targetModelName"}". Make sure value of x-ms-identifiers extension are valid property name of the array element.`, - }, - create(context) { - return { - modelProperty: (property: ModelProperty) => { - const type = property.type; - if (type.kind === "Model" && isArrayModelType(type)) { - if (isArrayMissingIdentifier(context.program, type, property)) { - context.reportDiagnostic({ - target: property, - codefixes: [createAddDecoratorCodeFix(property, "identifiers", [`#[""]`])], - }); - } - } - }, - }; - - function isArrayMissingIdentifier( - program: Program, - array: ArrayModelType, - property: ModelProperty, - ) { - const elementType = array.indexer.value; - if (elementType.kind !== "Model") { - return false; - } - - if (isArmCommonType(elementType)) { - return false; - } - - if (getProperty(elementType, "id") || getProperty(elementType, "name")) { - return false; - } - - const armIdentifiers = getArmIdentifiers(program, property); - const armKeyIdentifiers = getArmKeyIdentifiers(program, array); - const identifiers = armIdentifiers ?? armKeyIdentifiers; - - if (identifiers === undefined) { - return true; - } - - for (const propIdentifier of identifiers) { - if (typeof propIdentifier === "string") { - const props = propIdentifier.replace(/^\//, "").split("/"); - let element = elementType; - for (const prop of props) { - if (element === undefined || element.kind !== "Model") { - context.reportDiagnostic({ - messageId: "missingProperty", - format: { propertyName: prop, targetModelName: element?.name }, - target: property, - }); - return false; - } - const propertyValue = getProperty(element, prop); - if (propertyValue === undefined) { - context.reportDiagnostic({ - messageId: "missingProperty", - format: { propertyName: prop, targetModelName: elementType.name }, - target: property, - }); - } - - element = propertyValue?.type as ArrayModelType; - } - } else { - context.reportDiagnostic({ - messageId: "notArray", - format: { valueType: typeof propIdentifier }, - target: property, - }); - } - } - - return false; - } - }, -}); diff --git a/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts b/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts deleted file mode 100644 index c13d8c360a..0000000000 --- a/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Tester } from "#test/tester.js"; -import { - LinterRuleTester, - TesterInstance, - createLinterRuleTester, -} from "@typespec/compiler/testing"; -import { beforeEach, it } from "vitest"; - -import { interfacesRule } from "../../src/rules/arm-resource-interfaces.js"; - -let runner: TesterInstance; -let tester: LinterRuleTester; - -beforeEach(async () => { - runner = await Tester.createInstance(); - tester = createLinterRuleTester( - runner, - interfacesRule, - "@azure-tools/typespec-azure-resource-manager", - ); -}); - -it("Detects interfaces without @armResourceOperations", async () => { - await tester - .expect( - ` - @armProviderNamespace - namespace Microsoft.Foo; - - model FooResource is TrackedResource<{}> { - ...ResourceNameParameter; - } - - interface FooResources extends TrackedResourceOperations {} - `, - ) - .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator", - message: "Each resource interface must have an @armResourceOperations decorator.", - }); -}); diff --git a/packages/typespec-azure-resource-manager/test/rules/missing-x-ms-identifiers.test.ts b/packages/typespec-azure-resource-manager/test/rules/missing-x-ms-identifiers.test.ts deleted file mode 100644 index 3f51a36c21..0000000000 --- a/packages/typespec-azure-resource-manager/test/rules/missing-x-ms-identifiers.test.ts +++ /dev/null @@ -1,214 +0,0 @@ -import { Tester } from "#test/tester.js"; -import { - LinterRuleTester, - TesterInstance, - createLinterRuleTester, -} from "@typespec/compiler/testing"; -import { beforeEach, describe, it } from "vitest"; - -import { missingXmsIdentifiersRule } from "../../src/rules/missing-x-ms-identifiers.js"; - -let runner: TesterInstance; -let tester: LinterRuleTester; - -beforeEach(async () => { - runner = await Tester.createInstance(); - tester = createLinterRuleTester( - runner, - missingXmsIdentifiersRule, - "@azure-tools/typespec-azure-resource-manager", - ); -}); - -it("emit warning for array of model without x-ms-identifiers", async () => { - await tester - .expect( - ` - model Foo { - bar: Bar[]; - } - - model Bar { - customName: string; - } - `, - ) - .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers", - message: `Missing identifying properties of objects in the array item, please add @identifiers(#[""]) to specify it. If there are no appropriate identifying properties, please add @identifiers(#[]).`, - }); -}); - -it("emit diagnostic when x-ms-identifiers property names are not found in the target type", async () => { - await tester - .expect( - ` - model Foo { - @identifiers(#["not-a-prop"]) - bar: Bar[]; - } - - model Bar { - customName: string; - } - `, - ) - .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers", - message: `Property "not-a-prop" is not found in "Bar". Make sure value of x-ms-identifiers extension are valid property name of the array element.`, - }); -}); - -it(`doesn't emit diagnostic if @identifiers(...) is specified`, async () => { - await tester - .expect( - ` - model Foo { - @identifiers(#["customName"]) - bar: Bar[]; - } - - model Bar { - customName: string; - } - `, - ) - .toBeValid(); -}); - -it(`doesn't emit diagnostic if x-ms-identifiers property is defined in a base class`, async () => { - await tester - .expect( - ` - model Foo { - @identifiers(#["name"]) - bar: Child[]; - } - - model Child extends Base { - other: string; - } - - model Base { name: string;} - `, - ) - .toBeValid(); -}); - -it(`doesn't emit diagnostic if element is a primitive type`, async () => { - await tester - .expect( - ` - model Foo { - bar: Bar[]; - } - - model Bar { - id: string; - } - `, - ) - .toBeValid(); -}); - -it("allow x-ms-identifiers from keys", async () => { - await tester - .expect( - ` - model Pet { - pet: Dog[]; - } - - model Dog { - food: Food; - } - - model Food { - @key - brand: string; - } - `, - ) - .toBeValid(); -}); - -it("allow x-ms-identifiers from keys on default identifiers", async () => { - await tester - .expect( - ` - model Pet { - pet: Dog[]; - } - - model Dog { - name: string; - } - `, - ) - .toBeValid(); -}); - -it("allow x-ms-identifiers from identifiers decorator", async () => { - await tester - .expect( - ` - model Pet { - @identifiers(#["name"]) - pet: Dog[]; - } - - model Dog { - name: string; - } - `, - ) - .toBeValid(); -}); - -it("emit diagnostic if a section is not found", async () => { - await tester - .expect( - ` - model Pet { - @identifiers(#["food/brand"]) - pet: Dog[]; - } - - model Dog { - food: string; - brand: string; - } - `, - ) - .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers", - message: `Property "brand" is not found in "string". Make sure value of x-ms-identifiers extension are valid property name of the array element.`, - }); -}); - -describe("codefix", () => { - it("adds @identifiers decorator", async () => { - await tester - .expect( - ` - model Foo { - bar: Bar[]; - } - - model Bar { - customName: string; - } - `, - ) - .applyCodeFix("add-decorator-identifiers").toEqual(` - model Foo { - @identifiers(#[""]) - bar: Bar[]; - } - - model Bar { - customName: string; - } - `); - }); -}); diff --git a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts index 303d66537b..9d1939fcf0 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts @@ -83,11 +83,9 @@ export default { "@azure-tools/typespec-azure-resource-manager/arm-resource-operation": true, "@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation": true, "@azure-tools/typespec-azure-resource-manager/empty-updateable-properties": true, - "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator": true, "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb": true, "@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation": true, "@azure-tools/typespec-azure-resource-manager/lro-location-header": true, - "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers": true, "@azure-tools/typespec-azure-resource-manager/no-response-body": true, "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint": true, "@azure-tools/typespec-azure-resource-manager/patch-envelope": true, diff --git a/website/src/content/docs/docs/howtos/ARM/rpc-guidelines-coverage.md b/website/src/content/docs/docs/howtos/ARM/rpc-guidelines-coverage.md index ab6676ff36..3c06b60a05 100644 --- a/website/src/content/docs/docs/howtos/ARM/rpc-guidelines-coverage.md +++ b/website/src/content/docs/docs/howtos/ARM/rpc-guidelines-coverage.md @@ -180,18 +180,16 @@ The following sections provide a more detailed breakdown of coverage organized b The following TypeSpec linting rules enforce ARM conventions that are not explicitly called out as individual RPC guidelines but support overall ARM compliance: -| TypeSpec Rule | Description | -| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -| `arm/arm-common-types-version` | Requires specifying the ARM common-types version using `@armCommonTypesVersion`. | -| [`arm/arm-no-record`](/docs/libraries/azure-resource-manager/rules/arm-no-record) | Prevents use of `Record` types for ARM resources, which produce `additionalProperties` in OpenAPI. | -| `arm/arm-resource-duplicate-property` | Warns about duplicate properties in resource definitions. | -| `arm/arm-resource-interface-requires-decorator` | Requires `@armResourceOperations` decorator on resource interfaces. | -| [`arm/arm-resource-name-pattern`](/docs/libraries/azure-resource-manager/rules/resource-name-pattern) | Requires a `pattern` restriction on resource name parameters. | -| `arm/improper-subscription-list-operation` | Ensures tenant and extension resources don't define list-by-subscription operations. | -| [`arm/missing-x-ms-identifiers`](/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers) | Requires array properties to describe identifying properties with `x-ms-identifiers`. | -| [`arm/no-empty-model`](/docs/libraries/azure-resource-manager/rules/no-empty-model) | Prevents ARM properties with `type: object` that don't reference a model definition. | -| [`arm/no-override-props`](/docs/libraries/azure-resource-manager/rules/no-override-props) | Disallows redefining properties already defined in a base type. | -| [`arm/unsupported-type`](/docs/libraries/azure-resource-manager/rules/unsupported-type) | Checks for unsupported ARM types. | +| TypeSpec Rule | Description | +| ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `arm/arm-common-types-version` | Requires specifying the ARM common-types version using `@armCommonTypesVersion`. | +| [`arm/arm-no-record`](/docs/libraries/azure-resource-manager/rules/arm-no-record) | Prevents use of `Record` types for ARM resources, which produce `additionalProperties` in OpenAPI. | +| `arm/arm-resource-duplicate-property` | Warns about duplicate properties in resource definitions. | +| [`arm/arm-resource-name-pattern`](/docs/libraries/azure-resource-manager/rules/resource-name-pattern) | Requires a `pattern` restriction on resource name parameters. | +| `arm/improper-subscription-list-operation` | Ensures tenant and extension resources don't define list-by-subscription operations. | +| [`arm/no-empty-model`](/docs/libraries/azure-resource-manager/rules/no-empty-model) | Prevents ARM properties with `type: object` that don't reference a model definition. | +| [`arm/no-override-props`](/docs/libraries/azure-resource-manager/rules/no-override-props) | Disallows redefining properties already defined in a base type. | +| [`arm/unsupported-type`](/docs/libraries/azure-resource-manager/rules/unsupported-type) | Checks for unsupported ARM types. | ## Rules Not Enforceable Through Linting — Service Owner Responsibility diff --git a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/linter.md b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/linter.md index 6b91668215..4b265b1b52 100644 --- a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/linter.md +++ b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/linter.md @@ -20,44 +20,42 @@ Available ruleSets: ## Rules -| Name | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-child-resources`](../rules/arm-agent-base-type-child-resources.md) | Resources decorated with @azureBaseType for the Agent base type must have both a Conversation and a Response child resource. | -| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-lifecycle-operations`](../rules/arm-agent-base-type-lifecycle-operations.md) | Conversation and Response child resources of an Agent must define create, read, update, and delete lifecycle operations. | -| [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](../rules/arm-no-record.md) | Don't use Record types for ARM resources. | -| [`@azure-tools/typespec-azure-resource-manager/arm-no-path-casing-conflicts`](../rules/arm-no-path-casing-conflicts.md) | Operation paths must be unique when compared case-insensitively. | -| [`@azure-tools/typespec-azure-resource-manager/no-override-props`](../rules/no-override-props.md) | Disallow redefining properties already defined in a base type. | -| [`@azure-tools/typespec-azure-resource-manager/arm-common-types-version`](../rules/arm-common-types-version.md) | Specify the ARM common-types version using @armCommonTypesVersion. | -| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](../rules/arm-delete-operation-response-codes.md) | Ensure delete operations have the appropriate status codes. | -| [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](../rules/arm-put-operation-response-codes.md) | Ensure put operations have the appropriate status codes. | -| [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](../rules/arm-post-operation-response-codes.md) | Ensure post operations have the appropriate status codes. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment`](../rules/arm-resource-action-no-segment.md) | `@armResourceAction` should not be used with `@segment`. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property`](../rules/arm-resource-duplicate-property.md) | Warn about duplicate properties in resources. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property`](../rules/arm-resource-invalid-envelope-property.md) | Check for invalid resource envelope properties. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format`](../rules/arm-resource-invalid-version-format.md) | Check for valid versions. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars`](../rules/arm-resource-key-invalid-chars.md) | Arm resource key must contain only alphanumeric characters. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern`](../rules/arm-resource-name-pattern.md) | The resource name parameter should be defined with a 'pattern' restriction. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response`](../rules/arm-resource-operation-response.md) | [RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars`](../rules/arm-resource-path-segment-invalid-chars.md) | Arm resource name must contain only alphanumeric characters. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state`](../rules/arm-resource-provisioning-state.md) | Check for properly configured provisioningState property. | -| [`@azure-tools/typespec-azure-resource-manager/version-progression`](../rules/version-progression.md) | Validate that ARM service versions all use unique dates and are declared in strictly increasing chronological order. | -| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-no-key`](../rules/arm-custom-resource-no-key.md) | Validate that custom resource contains a key property. | -| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-usage-discourage`](../rules/arm-custom-resource-usage-discourage.md) | Verify the usage of @customAzureResource decorator. | -| [`@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels`](../rules/beyond-nesting-levels.md) | Tracked Resources must use 3 or fewer levels of nesting. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation`](../rules/arm-resource-operation.md) | Validate ARM Resource operations. | -| [`@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation`](../rules/no-resource-delete-operation.md) | Check for resources that must have a delete operation. | -| [`@azure-tools/typespec-azure-resource-manager/empty-updateable-properties`](../rules/empty-updateable-properties.md) | Should have updateable properties. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator`](../rules/arm-resource-interface-requires-decorator.md) | Each resource interface must have an @armResourceOperations decorator. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb`](../rules/arm-resource-invalid-action-verb.md) | Actions must be HTTP Post or Get operations. | -| [`@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation`](../rules/improper-subscription-list-operation.md) | Tenant and Extension resources should not define a list by subscription operation. | -| [`@azure-tools/typespec-azure-resource-manager/lro-location-header`](../rules/lro-location-header.md) | A 202 response should include a Location response header. | -| [`@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers`](../rules/missing-x-ms-identifiers.md) | Array properties should describe their identifying properties with x-ms-identifiers. Decorate the property with @OpenAPI.extension("x-ms-identifiers", #[id-prop]) where "id-prop" is a list of the names of identifying properties in the item type. | -| [`@azure-tools/typespec-azure-resource-manager/no-response-body`](../rules/no-response-body.md) | Check that the body is empty for 202 and 204 responses, and not empty for other success (2xx) responses. | -| [`@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint`](../rules/missing-operations-endpoint.md) | Check for missing Operations interface. | -| [`@azure-tools/typespec-azure-resource-manager/patch-envelope`](../rules/patch-envelope.md) | Patch envelope properties should match the resource properties. | -| [`@azure-tools/typespec-azure-resource-manager/arm-resource-patch`](../rules/arm-resource-patch.md) | Validate ARM PATCH operations. | -| [`@azure-tools/typespec-azure-resource-manager/resource-name`](../rules/resource-name.md) | Check the resource name. | -| [`@azure-tools/typespec-azure-resource-manager/retry-after`](../rules/retry-after.md) | Check if retry-after header appears in response body. | -| [`@azure-tools/typespec-azure-resource-manager/unsupported-type`](../rules/unsupported-type.md) | Check for unsupported ARM types. | -| [`@azure-tools/typespec-azure-resource-manager/secret-prop`](../rules/secret-prop.md) | RPC-v1-13: Check that property with names indicating sensitive information(e.g. contains auth, password, token, secret, etc.) are marked with @secret decorator. | -| [`@azure-tools/typespec-azure-resource-manager/no-empty-model`](../rules/no-empty-model.md) | ARM Properties with type:object that don't reference a model definition are not allowed. ARM doesn't allow generic type definitions as this leads to bad customer experience. | +| Name | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-child-resources`](../rules/arm-agent-base-type-child-resources.md) | Resources decorated with @azureBaseType for the Agent base type must have both a Conversation and a Response child resource. | +| [`@azure-tools/typespec-azure-resource-manager/arm-agent-base-type-lifecycle-operations`](../rules/arm-agent-base-type-lifecycle-operations.md) | Conversation and Response child resources of an Agent must define create, read, update, and delete lifecycle operations. | +| [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](../rules/arm-no-record.md) | Don't use Record types for ARM resources. | +| [`@azure-tools/typespec-azure-resource-manager/arm-no-path-casing-conflicts`](../rules/arm-no-path-casing-conflicts.md) | Operation paths must be unique when compared case-insensitively. | +| [`@azure-tools/typespec-azure-resource-manager/no-override-props`](../rules/no-override-props.md) | Disallow redefining properties already defined in a base type. | +| [`@azure-tools/typespec-azure-resource-manager/arm-common-types-version`](../rules/arm-common-types-version.md) | Specify the ARM common-types version using @armCommonTypesVersion. | +| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](../rules/arm-delete-operation-response-codes.md) | Ensure delete operations have the appropriate status codes. | +| [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](../rules/arm-put-operation-response-codes.md) | Ensure put operations have the appropriate status codes. | +| [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](../rules/arm-post-operation-response-codes.md) | Ensure post operations have the appropriate status codes. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment`](../rules/arm-resource-action-no-segment.md) | `@armResourceAction` should not be used with `@segment`. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property`](../rules/arm-resource-duplicate-property.md) | Warn about duplicate properties in resources. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property`](../rules/arm-resource-invalid-envelope-property.md) | Check for invalid resource envelope properties. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format`](../rules/arm-resource-invalid-version-format.md) | Check for valid versions. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars`](../rules/arm-resource-key-invalid-chars.md) | Arm resource key must contain only alphanumeric characters. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern`](../rules/arm-resource-name-pattern.md) | The resource name parameter should be defined with a 'pattern' restriction. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response`](../rules/arm-resource-operation-response.md) | [RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars`](../rules/arm-resource-path-segment-invalid-chars.md) | Arm resource name must contain only alphanumeric characters. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state`](../rules/arm-resource-provisioning-state.md) | Check for properly configured provisioningState property. | +| [`@azure-tools/typespec-azure-resource-manager/version-progression`](../rules/version-progression.md) | Validate that ARM service versions all use unique dates and are declared in strictly increasing chronological order. | +| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-no-key`](../rules/arm-custom-resource-no-key.md) | Validate that custom resource contains a key property. | +| [`@azure-tools/typespec-azure-resource-manager/arm-custom-resource-usage-discourage`](../rules/arm-custom-resource-usage-discourage.md) | Verify the usage of @customAzureResource decorator. | +| [`@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels`](../rules/beyond-nesting-levels.md) | Tracked Resources must use 3 or fewer levels of nesting. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation`](../rules/arm-resource-operation.md) | Validate ARM Resource operations. | +| [`@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation`](../rules/no-resource-delete-operation.md) | Check for resources that must have a delete operation. | +| [`@azure-tools/typespec-azure-resource-manager/empty-updateable-properties`](../rules/empty-updateable-properties.md) | Should have updateable properties. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb`](../rules/arm-resource-invalid-action-verb.md) | Actions must be HTTP Post or Get operations. | +| [`@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation`](../rules/improper-subscription-list-operation.md) | Tenant and Extension resources should not define a list by subscription operation. | +| [`@azure-tools/typespec-azure-resource-manager/lro-location-header`](../rules/lro-location-header.md) | A 202 response should include a Location response header. | +| [`@azure-tools/typespec-azure-resource-manager/no-response-body`](../rules/no-response-body.md) | Check that the body is empty for 202 and 204 responses, and not empty for other success (2xx) responses. | +| [`@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint`](../rules/missing-operations-endpoint.md) | Check for missing Operations interface. | +| [`@azure-tools/typespec-azure-resource-manager/patch-envelope`](../rules/patch-envelope.md) | Patch envelope properties should match the resource properties. | +| [`@azure-tools/typespec-azure-resource-manager/arm-resource-patch`](../rules/arm-resource-patch.md) | Validate ARM PATCH operations. | +| [`@azure-tools/typespec-azure-resource-manager/resource-name`](../rules/resource-name.md) | Check the resource name. | +| [`@azure-tools/typespec-azure-resource-manager/retry-after`](../rules/retry-after.md) | Check if retry-after header appears in response body. | +| [`@azure-tools/typespec-azure-resource-manager/unsupported-type`](../rules/unsupported-type.md) | Check for unsupported ARM types. | +| [`@azure-tools/typespec-azure-resource-manager/secret-prop`](../rules/secret-prop.md) | RPC-v1-13: Check that property with names indicating sensitive information(e.g. contains auth, password, token, secret, etc.) are marked with @secret decorator. | +| [`@azure-tools/typespec-azure-resource-manager/no-empty-model`](../rules/no-empty-model.md) | ARM Properties with type:object that don't reference a model definition are not allowed. ARM doesn't allow generic type definitions as this leads to bad customer experience. | diff --git a/website/src/content/docs/docs/libraries/azure-resource-manager/rules/arm-resource-interface-requires-decorator.md b/website/src/content/docs/docs/libraries/azure-resource-manager/rules/arm-resource-interface-requires-decorator.md deleted file mode 100644 index 4597d615c6..0000000000 --- a/website/src/content/docs/docs/libraries/azure-resource-manager/rules/arm-resource-interface-requires-decorator.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: arm-resource-interface-requires-decorator ---- - -```text title="Full name" -@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator -``` - -Each resource interface must have an `@armResourceOperations` decorator to associate the interface with its ARM resource type. - -#### ❌ Incorrect - -```tsp -interface FooResources extends TrackedResourceOperations {} -``` - -#### ✅ Correct - -```tsp -@armResourceOperations(FooResource) -interface FooResources extends TrackedResourceOperations {} -``` diff --git a/website/src/content/docs/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers.md b/website/src/content/docs/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers.md deleted file mode 100644 index eee69646ee..0000000000 --- a/website/src/content/docs/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: missing-x-ms-identifiers ---- - -```text title=- Full name- -@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers -``` - -Array of models must explicity define which keys are used as identifiers using the `@identifiers` decorator. - -#### ❌ Incorrect - -```tsp -model Address { - city: string; - street: string; -} - -model ResourceProperties { - array: Address[]; -} -``` - -#### ✅ Correct - -```tsp -model ResourceProperties { - @identifiers(#["city", "street"]) - array: Address[]; -} -```