Skip to content

Commit

Permalink
Feedback: rename from arm-no-empty-model to no-empty-model
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitzelMendez committed Sep 18, 2024
1 parent 7c7987f commit b65afd8
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .chronus/changes/almend-Rule-2024-8-17-16-58-23.md
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-no-empty-model` rule
Add `no-empty-model` rule
2 changes: 1 addition & 1 deletion .chronus/changes/almend-Rule-2024-8-18-10-2-28.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ packages:
- "@azure-tools/typespec-azure-rulesets"
---

Add `arm-no-empty-model` rule to ruleset
Add `no-empty-model` rule to ruleset
2 changes: 1 addition & 1 deletion docs/libraries/azure-resource-manager/reference/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Available ruleSets:
| [`@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-put-operation-response-codes`](/libraries/azure-resource-manager/rules/put-operation-response-codes.md) | Ensure put operations have the appropriate status codes. |
| [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](/libraries/azure-resource-manager/rules/post-operation-response-codes.md) | Ensure post operations have the appropriate status codes. |
| `@azure-tools/typespec-azure-resource-manager/arm-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. |
| `@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. |
Expand All @@ -57,3 +56,4 @@ Available ruleSets:
| `@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. |
| [`@azure-tools/typespec-azure-resource-manager/no-empty-model`](/libraries/azure-resource-manager/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. |
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: arm-no-empty-model
title: no-empty-model
---

```text title=- Full name-
@azure-tools/typespec-azure-resource-manager/arm-no-empty-model
@azure-tools/typespec-azure-resource-manager/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.
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-azure-resource-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Available ruleSets:
| [`@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-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. |
| `@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. |
Expand All @@ -61,6 +60,7 @@ Available ruleSets:
| `@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`](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/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

Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-azure-resource-manager/src/linter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineLinter } from "@typespec/compiler";
import { armCommonTypesVersionRule } from "./rules/arm-common-types-version.js";
import { armDeleteResponseCodesRule } from "./rules/arm-delete-response-codes.js";
import { armNoEmptyModel } from "./rules/arm-no-empty-model.js";
import { armNoRecordRule } from "./rules/arm-no-record.js";
import { armPostResponseCodesRule } from "./rules/arm-post-response-codes.js";
import { armPutResponseCodesRule } from "./rules/arm-put-response-codes.js";
Expand All @@ -24,6 +23,7 @@ import { envelopePropertiesRules } from "./rules/envelope-properties.js";
import { listBySubscriptionRule } from "./rules/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 { noResponseBodyRule } from "./rules/no-response-body.js";
import { operationsInterfaceMissingRule } from "./rules/operations-interface-missing.js";
import { patchEnvelopePropertiesRules } from "./rules/patch-envelope-properties.js";
Expand All @@ -37,7 +37,6 @@ const rules = [
armDeleteResponseCodesRule,
armPutResponseCodesRule,
armPostResponseCodesRule,
armNoEmptyModel,
armResourceActionNoSegmentRule,
armResourceDuplicatePropertiesRule,
armResourceEnvelopeProperties,
Expand All @@ -63,6 +62,7 @@ const rules = [
resourceNameRule,
retryAfterRule,
unsupportedTypeRule,
noEmptyModel,
];

export const $linter = defineLinter({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createRule, Model } from "@typespec/compiler";

export const armNoEmptyModel = createRule({
name: "arm-no-empty-model",
export const noEmptyModel = createRule({
name: "no-empty-model",
severity: "warning",
description:
"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.",
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-empty-model",
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-empty-model",
messages: {
default: "Properties with type:object must have definition of a reference model.",
extends:
Expand All @@ -16,7 +16,7 @@ export const armNoEmptyModel = createRule({
model: (model: Model) => {
if (model.properties.size === 0) {
context.reportDiagnostic({
code: "arm-no-empty-model",
code: "no-empty-model",
target: model,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
createLinterRuleTester,
} from "@typespec/compiler/testing";
import { beforeEach, describe, it } from "vitest";
import { armNoEmptyModel } from "../../src/rules/arm-no-empty-model.js";
import { noEmptyModel } from "../../src/rules/no-empty-model.js";
import { createAzureResourceManagerTestRunner } from "../test-host.js";

const armDef = `
Expand All @@ -21,7 +21,7 @@ describe("typespec-azure-resource-manager: arm properties type-object no definit
runner = await createAzureResourceManagerTestRunner();
tester = createLinterRuleTester(
runner,
armNoEmptyModel,
noEmptyModel,
"@azure-tools/typespec-azure-resource-manager",
);
});
Expand All @@ -37,7 +37,7 @@ describe("typespec-azure-resource-manager: arm properties type-object no definit
`,
)
.toEmitDiagnostics({
code: "@azure-tools/typespec-azure-resource-manager/arm-no-empty-model",
code: "@azure-tools/typespec-azure-resource-manager/no-empty-model",
message: "Properties with type:object must have definition of a reference model.",
});
});
Expand All @@ -51,7 +51,7 @@ describe("typespec-azure-resource-manager: arm properties type-object no definit
`,
)
.toEmitDiagnostics({
code: "@azure-tools/typespec-azure-resource-manager/arm-no-empty-model",
code: "@azure-tools/typespec-azure-resource-manager/no-empty-model",
message: "Properties with type:object must have definition of a reference model.",
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {

// Azure resource manager
"@azure-tools/typespec-azure-resource-manager/arm-no-record": true,
"@azure-tools/typespec-azure-resource-manager/arm-no-empty-model": true,
"@azure-tools/typespec-azure-resource-manager/no-empty-model": true,
"@azure-tools/typespec-azure-resource-manager/arm-common-types-version": true,
"@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes": true,
"@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes": true,
Expand Down

0 comments on commit b65afd8

Please sign in to comment.