Skip to content

Commit

Permalink
Rename rule to "arm-no-record"
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Feb 26, 2024
1 parent 20f7be7 commit 5fdddad
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Add `arm-avoid-additional-properties` rule.
Add `arm-no-record` rule.
53 changes: 27 additions & 26 deletions docs/libraries/azure-resource-manager/reference/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,30 @@ Available ruleSets:

## Rules

| Name | Description |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `@azure-tools/typespec-azure-resource-manager/arm-common-types-version` | Specify the ARM common-types version using @armCommonTypesVersion. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment` | `@armResourceAction` should not be used with `@segment`. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property` | Warn about duplicate properties in resources. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property` | Check for invalid resource envelope properties. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format` | Check for valid versions. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars` | Arm resource key must contain only alphanumeric characters. |
| `@azure-tools/typespec-azure-resource-manager/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` | Arm resource name must contain only alphanumeric characters. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state` | Check for properly configured provisioningState property. |
| `@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels` | Tracked Resources must use 3 or fewer levels of nesting. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-operation` | Validate ARM Resource operations. |
| `@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation` | Check for resources that must have a delete operation. |
| `@azure-tools/typespec-azure-resource-manager/empty-updateable-properties` | Should have updateable properties. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator` | Each resource interface must have an @armResourceOperations decorator. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb` | Actions must be HTTP Post operations. |
| `@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation` | Tenant and Extension resources should not define a list by subscription operation. |
| [`@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers`](/libraries/azure-resource-manager/rules/missing-x-ms-identifiers.md) | Azure services should not use enums. |
| `@azure-tools/typespec-azure-resource-manager/no-response-body` | The body of 202 response should be empty. |
| `@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint` | Check for missing Operations interface. |
| `@azure-tools/typespec-azure-resource-manager/patch-envelope` | Patch envelope properties should match the resource properties. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-patch` | Validate ARM PATCH operations. |
| `@azure-tools/typespec-azure-resource-manager/resource-name` | Check the resource name. |
| `@azure-tools/typespec-azure-resource-manager/retry-after` | Check if retry-after header appears in response body. |
| [`@azure-tools/typespec-azure-resource-manager/unsupported-type`](/libraries/azure-resource-manager/rules/unsupported-type.md) | Check for unsupported ARM types. |
| Name | Description |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `@azure-tools/typespec-azure-resource-manager/arm-common-types-version` | Specify the ARM common-types version using @armCommonTypesVersion. |
| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](/libraries/azure-resource-manager/rules/delete-operation-response-codes.md) | Ensure delete operations have the appropriate status codes. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment` | `@armResourceAction` should not be used with `@segment`. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property` | Warn about duplicate properties in resources. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property` | Check for invalid resource envelope properties. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format` | Check for valid versions. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars` | Arm resource key must contain only alphanumeric characters. |
| `@azure-tools/typespec-azure-resource-manager/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` | Arm resource name must contain only alphanumeric characters. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state` | Check for properly configured provisioningState property. |
| `@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels` | Tracked Resources must use 3 or fewer levels of nesting. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-operation` | Validate ARM Resource operations. |
| `@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation` | Check for resources that must have a delete operation. |
| `@azure-tools/typespec-azure-resource-manager/empty-updateable-properties` | Should have updateable properties. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator` | Each resource interface must have an @armResourceOperations decorator. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb` | Actions must be HTTP Post operations. |
| `@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation` | Tenant and Extension resources should not define a list by subscription operation. |
| [`@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers`](/libraries/azure-resource-manager/rules/missing-x-ms-identifiers.md) | Azure services should not use enums. |
| `@azure-tools/typespec-azure-resource-manager/no-response-body` | The body of 202 response should be empty. |
| `@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint` | Check for missing Operations interface. |
| `@azure-tools/typespec-azure-resource-manager/patch-envelope` | Patch envelope properties should match the resource properties. |
| `@azure-tools/typespec-azure-resource-manager/arm-resource-patch` | Validate ARM PATCH operations. |
| `@azure-tools/typespec-azure-resource-manager/resource-name` | Check the resource name. |
| `@azure-tools/typespec-azure-resource-manager/retry-after` | Check if retry-after header appears in response body. |
| [`@azure-tools/typespec-azure-resource-manager/unsupported-type`](/libraries/azure-resource-manager/rules/unsupported-type.md) | Check for unsupported ARM types. |

This file was deleted.

67 changes: 67 additions & 0 deletions docs/libraries/azure-resource-manager/rules/no-record.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: no-record
---

```text title=- Full name-
@azure-tools/typespec-azure-resource-manager/no-record
```

ARM requires Resource provider teams to define types explicitly. This is to ensure good customer experience in terms of the discoverability of concrete type definitions.

#### ❌ Incorrect

```tsp
model Address extends Record<string> {}
```

#### ✅ Correct

```tsp
model Address {
street: string;
city: string;
state: string;
country: string;
postalCode: string;
}
```

#### ❌ Incorrect

```tsp
model Address {
address: Record<string>;
city: string;
state: string;
}
```

#### ✅ Correct

```tsp
model Address {
street: string;
city: string;
state: string;
country: string;
postalCode: string;
}
```

#### ❌ Incorrect

```tsp
model Address is Record<string>;
```

#### ✅ Correct

```tsp
model Address {
street: string;
city: string;
state: string;
country: string;
postalCode: string;
}
```
Loading

0 comments on commit 5fdddad

Please sign in to comment.