From 507e4bedc9eaf421daa7f86d8f1ee43591bb7910 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 20 Aug 2026 13:23:21 +0800 Subject: [PATCH 1/3] Promote enum instead of boolean rule Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c5815a0-1862-43b9-bbb2-dfbe08b7606e --- ...ead-of-boolean-rule-2026-08-20-13-13-00.md | 8 ++ packages/typespec-azure-core/README.md | 1 + packages/typespec-azure-core/src/linter.ts | 2 + .../src/rules/enum-instead-of-boolean.md | 51 ++++++++++ .../src/rules/enum-instead-of-boolean.ts | 57 +++++++++++ .../rules/enum-instead-of-boolean.test.ts | 94 +++++++++++++++++++ .../src/rulesets/data-plane.ts | 1 + .../src/rulesets/resource-manager.ts | 1 + .../libraries/azure-core/reference/linter.md | 1 + 9 files changed, 216 insertions(+) create mode 100644 .chronus/changes/add-enum-instead-of-boolean-rule-2026-08-20-13-13-00.md create mode 100644 packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md create mode 100644 packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts create mode 100644 packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts diff --git a/.chronus/changes/add-enum-instead-of-boolean-rule-2026-08-20-13-13-00.md b/.chronus/changes/add-enum-instead-of-boolean-rule-2026-08-20-13-13-00.md new file mode 100644 index 0000000000..defe449c75 --- /dev/null +++ b/.chronus/changes/add-enum-instead-of-boolean-rule-2026-08-20-13-13-00.md @@ -0,0 +1,8 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-azure-core" + - "@azure-tools/typespec-azure-rulesets" +--- + +Add the `enum-instead-of-boolean` lint rule that recommends descriptive extensible enums instead of boolean API shapes when semantic values matter. diff --git a/packages/typespec-azure-core/README.md b/packages/typespec-azure-core/README.md index 5e5a3a7f18..bbdd339d7f 100644 --- a/packages/typespec-azure-core/README.md +++ b/packages/typespec-azure-core/README.md @@ -35,6 +35,7 @@ Available ruleSets: | [`@azure-tools/typespec-azure-core/byos`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/byos) | Use the BYOS pattern recommended for Azure Services. | | [`@azure-tools/typespec-azure-core/casing-style`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/casing-style) | Ensure proper casing style. | | [`@azure-tools/typespec-azure-core/composition-over-inheritance`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/composition-over-inheritance) | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. | +| [`@azure-tools/typespec-azure-core/enum-instead-of-boolean`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/enum-instead-of-boolean) | Boolean properties should use descriptive extensible enums when semantic values matter. | | [`@azure-tools/typespec-azure-core/known-encoding`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/known-encoding) | Check for supported encodings. | | [`@azure-tools/typespec-azure-core/long-running-polling-operation-required`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/long-running-polling-operation-required) | Long-running operations should have a linked polling operation. | | [`@azure-tools/typespec-azure-core/no-case-mismatch`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-case-mismatch) | Validate that no two types have the same name with different casing. | diff --git a/packages/typespec-azure-core/src/linter.ts b/packages/typespec-azure-core/src/linter.ts index e13abd9932..0db6a3643e 100644 --- a/packages/typespec-azure-core/src/linter.ts +++ b/packages/typespec-azure-core/src/linter.ts @@ -4,6 +4,7 @@ import { badRecordTypeRule } from "./rules/bad-record-type.js"; import { byosRule } from "./rules/byos.js"; import { casingRule } from "./rules/casing-style.js"; import { compositionOverInheritanceRule } from "./rules/composition-over-inheritance.js"; +import { enumInsteadOfBooleanRule } from "./rules/enum-instead-of-boolean.js"; import { friendlyNameRule } from "./rules/friendly-name.js"; import { knownEncodingRule } from "./rules/known-encoding.js"; import { longRunningOperationsRequirePollingOperation } from "./rules/lro-polling-operation.js"; @@ -49,6 +50,7 @@ const rules = [ byosRule, casingRule, compositionOverInheritanceRule, + enumInsteadOfBooleanRule, knownEncodingRule, longRunningOperationsRequirePollingOperation, noCaseMismatchRule, diff --git a/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md b/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md new file mode 100644 index 0000000000..6d63651daa --- /dev/null +++ b/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md @@ -0,0 +1,51 @@ +Boolean values can be hard for API users to understand when the property or payload represents a +domain state, option, or mode. Prefer a descriptive extensible enum modeled as a union so future +values can be added without a breaking change. + +## Impact + +- **Area:** SDK, API + +Boolean shapes can make generated clients less readable and can force future breaking changes if the +API later needs more than two values. + +## LintDiff Equivalent + +This rule corresponds to the LintDiff rule `EnumInsteadOfBoolean`. + +#### Incorrect + +```tsp +model Widget { + enabled: boolean; +} +``` + +```tsp +@get +op isWidgetEnabled(): boolean; +``` + +#### Correct + +```tsp +union WidgetState { + Enabled: "Enabled", + Disabled: "Disabled", + string, +} + +model Widget { + state: WidgetState; +} +``` + +```tsp +@get +op getWidgetState(): WidgetState; +``` + +## Suppression + +Suppress this rule only when the value is inherently boolean and is unlikely to grow additional +states, such as a simple yes/no capability. diff --git a/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts b/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts new file mode 100644 index 0000000000..fb046abd51 --- /dev/null +++ b/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts @@ -0,0 +1,57 @@ +import type { Type } from "@typespec/compiler"; +import { createRule, fileRef } from "@typespec/compiler"; +import { getHttpOperation } from "@typespec/http"; + +export const enumInsteadOfBooleanRule = createRule({ + name: "enum-instead-of-boolean", + docs: fileRef.fromPackageRoot("src/rules/enum-instead-of-boolean.md"), + description: + "Boolean properties should use descriptive extensible enums when semantic values matter.", + severity: "warning", + url: "https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/enum-instead-of-boolean", + messages: { + default: + "Consider using an extensible enum instead of a boolean property so the API shape is more descriptive.", + }, + create(context) { + return { + modelProperty: (property) => { + if (!isBooleanScalar(property)) { + return; + } + + context.reportDiagnostic({ + target: property, + }); + }, + operation: (operation) => { + const [httpOperation] = getHttpOperation(context.program, operation); + + for (const response of httpOperation.responses) { + if (isBooleanScalar(response.type)) { + context.reportDiagnostic({ + target: operation, + }); + continue; + } + + for (const content of response.responses) { + if (content.body === undefined || !isBooleanScalar(content.body.type)) { + continue; + } + + context.reportDiagnostic({ + target: content.body.property ?? operation, + }); + } + } + }, + }; + }, +}); + +function isBooleanScalar(type: Type): boolean { + return type.kind === "ModelProperty" + ? isBooleanScalar(type.type) + : type.kind === "Scalar" && type.name === "boolean"; +} diff --git a/packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts b/packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts new file mode 100644 index 0000000000..8fd7d78b2c --- /dev/null +++ b/packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts @@ -0,0 +1,94 @@ +import { Tester } from "#test/test-host.js"; +import { type LinterRuleTester, createLinterRuleTester } from "@typespec/compiler/testing"; +import { beforeEach, describe, it } from "vitest"; +import { enumInsteadOfBooleanRule } from "../../src/rules/enum-instead-of-boolean.js"; + +let tester: LinterRuleTester; + +beforeEach(async () => { + const runner = await Tester.createInstance(); + tester = createLinterRuleTester( + runner, + enumInsteadOfBooleanRule, + "@azure-tools/typespec-azure-core", + ); +}); + +describe("boolean shapes should use descriptive extensible enums", () => { + it("emits warning for boolean model properties", async () => { + await tester + .expect( + ` + model Widget { + enabled: boolean; + } + `, + ) + .toEmitDiagnostics({ + code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + message: + "Consider using an extensible enum instead of a boolean property so the API shape is more descriptive.", + }); + }); + + it("emits warning for boolean path parameters", async () => { + await tester + .expect( + ` + @route("/widgets/{enabled}") + @get + op getWidget(@path enabled: boolean): string; + `, + ) + .toEmitDiagnostics({ + code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + }); + }); + + it("emits warning for boolean request bodies", async () => { + await tester + .expect( + ` + @post + op checkWidget(@body body: boolean): string; + `, + ) + .toEmitDiagnostics({ + code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + }); + }); + + it("emits warning for boolean response bodies", async () => { + await tester + .expect( + ` + @get + op isWidgetEnabled(): boolean; + `, + ) + .toEmitDiagnostics({ + code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + }); + }); + + it("allows comparable non-boolean shapes", async () => { + await tester + .expect( + ` + union WidgetState { + Enabled: "Enabled", + Disabled: "Disabled", + string, + } + + model Widget { + state: WidgetState; + } + + @post + op checkWidget(@body body: WidgetState): WidgetState; + `, + ) + .toBeValid(); + }); +}); diff --git a/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts b/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts index 9f9314e74c..0a7a0aa734 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts @@ -8,6 +8,7 @@ export default { "@azure-tools/typespec-azure-core/byos": true, "@azure-tools/typespec-azure-core/casing-style": true, "@azure-tools/typespec-azure-core/composition-over-inheritance": true, + "@azure-tools/typespec-azure-core/enum-instead-of-boolean": true, "@azure-tools/typespec-azure-core/use-extensible-enum": true, "@azure-tools/typespec-azure-core/known-encoding": true, "@azure-tools/typespec-azure-core/long-running-polling-operation-required": true, diff --git a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts index 1167301d2f..b9864dcb36 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts @@ -9,6 +9,7 @@ export default { "@azure-tools/typespec-azure-core/byos": true, "@azure-tools/typespec-azure-core/casing-style": true, "@azure-tools/typespec-azure-core/composition-over-inheritance": true, + "@azure-tools/typespec-azure-core/enum-instead-of-boolean": true, "@azure-tools/typespec-azure-core/use-extensible-enum": true, "@azure-tools/typespec-azure-core/known-encoding": true, "@azure-tools/typespec-azure-core/long-running-polling-operation-required": true, diff --git a/website/src/content/docs/docs/libraries/azure-core/reference/linter.md b/website/src/content/docs/docs/libraries/azure-core/reference/linter.md index 1b286c74a4..d3c6924204 100644 --- a/website/src/content/docs/docs/libraries/azure-core/reference/linter.md +++ b/website/src/content/docs/docs/libraries/azure-core/reference/linter.md @@ -29,6 +29,7 @@ Available ruleSets: | [`@azure-tools/typespec-azure-core/byos`](../rules/byos.md) | Use the BYOS pattern recommended for Azure Services. | | [`@azure-tools/typespec-azure-core/casing-style`](../rules/casing-style.md) | Ensure proper casing style. | | [`@azure-tools/typespec-azure-core/composition-over-inheritance`](../rules/composition-over-inheritance.md) | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. | +| [`@azure-tools/typespec-azure-core/enum-instead-of-boolean`](../rules/enum-instead-of-boolean.md) | Boolean properties should use descriptive extensible enums when semantic values matter. | | [`@azure-tools/typespec-azure-core/known-encoding`](../rules/known-encoding.md) | Check for supported encodings. | | [`@azure-tools/typespec-azure-core/long-running-polling-operation-required`](../rules/long-running-polling-operation-required.md) | Long-running operations should have a linked polling operation. | | [`@azure-tools/typespec-azure-core/no-case-mismatch`](../rules/no-case-mismatch.md) | Validate that no two types have the same name with different casing. | From 262671562f38ec6dd74bb8b9087206ebf0f87bca Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 21 Aug 2026 14:01:26 +0800 Subject: [PATCH 2/3] Apply TypeSpec enum rule naming Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ed00e6d-dd0a-40f7-8871-ee32f0f371fb --- packages/typespec-azure-core/README.md | 2 +- packages/typespec-azure-core/src/linter.ts | 4 ++-- ...-of-boolean.md => use-enum-instead-of-boolean.md} | 8 ++++++++ ...-of-boolean.ts => use-enum-instead-of-boolean.ts} | 8 ++++---- ...n.test.ts => use-enum-instead-of-boolean.test.ts} | 12 ++++++------ .../src/rulesets/data-plane.ts | 2 +- .../src/rulesets/resource-manager.ts | 2 +- .../docs/libraries/azure-core/reference/linter.md | 2 +- 8 files changed, 24 insertions(+), 16 deletions(-) rename packages/typespec-azure-core/src/rules/{enum-instead-of-boolean.md => use-enum-instead-of-boolean.md} (87%) rename packages/typespec-azure-core/src/rules/{enum-instead-of-boolean.ts => use-enum-instead-of-boolean.ts} (87%) rename packages/typespec-azure-core/test/rules/{enum-instead-of-boolean.test.ts => use-enum-instead-of-boolean.test.ts} (81%) diff --git a/packages/typespec-azure-core/README.md b/packages/typespec-azure-core/README.md index bbdd339d7f..32074a6325 100644 --- a/packages/typespec-azure-core/README.md +++ b/packages/typespec-azure-core/README.md @@ -35,7 +35,7 @@ Available ruleSets: | [`@azure-tools/typespec-azure-core/byos`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/byos) | Use the BYOS pattern recommended for Azure Services. | | [`@azure-tools/typespec-azure-core/casing-style`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/casing-style) | Ensure proper casing style. | | [`@azure-tools/typespec-azure-core/composition-over-inheritance`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/composition-over-inheritance) | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. | -| [`@azure-tools/typespec-azure-core/enum-instead-of-boolean`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/enum-instead-of-boolean) | Boolean properties should use descriptive extensible enums when semantic values matter. | +| [`@azure-tools/typespec-azure-core/use-enum-instead-of-boolean`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/use-enum-instead-of-boolean) | Boolean properties should use descriptive extensible enums when semantic values matter. | | [`@azure-tools/typespec-azure-core/known-encoding`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/known-encoding) | Check for supported encodings. | | [`@azure-tools/typespec-azure-core/long-running-polling-operation-required`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/long-running-polling-operation-required) | Long-running operations should have a linked polling operation. | | [`@azure-tools/typespec-azure-core/no-case-mismatch`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-case-mismatch) | Validate that no two types have the same name with different casing. | diff --git a/packages/typespec-azure-core/src/linter.ts b/packages/typespec-azure-core/src/linter.ts index 0db6a3643e..be33debd16 100644 --- a/packages/typespec-azure-core/src/linter.ts +++ b/packages/typespec-azure-core/src/linter.ts @@ -4,7 +4,6 @@ import { badRecordTypeRule } from "./rules/bad-record-type.js"; import { byosRule } from "./rules/byos.js"; import { casingRule } from "./rules/casing-style.js"; import { compositionOverInheritanceRule } from "./rules/composition-over-inheritance.js"; -import { enumInsteadOfBooleanRule } from "./rules/enum-instead-of-boolean.js"; import { friendlyNameRule } from "./rules/friendly-name.js"; import { knownEncodingRule } from "./rules/known-encoding.js"; import { longRunningOperationsRequirePollingOperation } from "./rules/lro-polling-operation.js"; @@ -40,6 +39,7 @@ import { requireVersionedRule } from "./rules/require-versioned.js"; import { responseSchemaMultiStatusCodeRule } from "./rules/response-schema-multi-status-code.js"; import { rpcOperationRequestBodyRule } from "./rules/rpc-operation-request-body.js"; import { spreadDiscriminatedModelRule } from "./rules/spread-discriminated-model.js"; +import { useEnumInsteadOfBooleanRule } from "./rules/use-enum-instead-of-boolean.js"; import { useStandardNames } from "./rules/use-standard-names.js"; import { useStandardOperations } from "./rules/use-standard-operations.js"; @@ -50,7 +50,7 @@ const rules = [ byosRule, casingRule, compositionOverInheritanceRule, - enumInsteadOfBooleanRule, + useEnumInsteadOfBooleanRule, knownEncodingRule, longRunningOperationsRequirePollingOperation, noCaseMismatchRule, diff --git a/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md b/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md similarity index 87% rename from packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md rename to packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md index 6d63651daa..16a0e00a78 100644 --- a/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.md +++ b/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md @@ -1,3 +1,11 @@ +--- +title: "use-enum-instead-of-boolean" +--- + +```text title="Full name" +@azure-tools/typespec-azure-core/use-enum-instead-of-boolean +``` + Boolean values can be hard for API users to understand when the property or payload represents a domain state, option, or mode. Prefer a descriptive extensible enum modeled as a union so future values can be added without a breaking change. diff --git a/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts b/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.ts similarity index 87% rename from packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts rename to packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.ts index fb046abd51..16d0696ccd 100644 --- a/packages/typespec-azure-core/src/rules/enum-instead-of-boolean.ts +++ b/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.ts @@ -2,13 +2,13 @@ import type { Type } from "@typespec/compiler"; import { createRule, fileRef } from "@typespec/compiler"; import { getHttpOperation } from "@typespec/http"; -export const enumInsteadOfBooleanRule = createRule({ - name: "enum-instead-of-boolean", - docs: fileRef.fromPackageRoot("src/rules/enum-instead-of-boolean.md"), +export const useEnumInsteadOfBooleanRule = createRule({ + name: "use-enum-instead-of-boolean", + docs: fileRef.fromPackageRoot("src/rules/use-enum-instead-of-boolean.md"), description: "Boolean properties should use descriptive extensible enums when semantic values matter.", severity: "warning", - url: "https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/enum-instead-of-boolean", + url: "https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/use-enum-instead-of-boolean", messages: { default: "Consider using an extensible enum instead of a boolean property so the API shape is more descriptive.", diff --git a/packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts b/packages/typespec-azure-core/test/rules/use-enum-instead-of-boolean.test.ts similarity index 81% rename from packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts rename to packages/typespec-azure-core/test/rules/use-enum-instead-of-boolean.test.ts index 8fd7d78b2c..212eb8a287 100644 --- a/packages/typespec-azure-core/test/rules/enum-instead-of-boolean.test.ts +++ b/packages/typespec-azure-core/test/rules/use-enum-instead-of-boolean.test.ts @@ -1,7 +1,7 @@ import { Tester } from "#test/test-host.js"; import { type LinterRuleTester, createLinterRuleTester } from "@typespec/compiler/testing"; import { beforeEach, describe, it } from "vitest"; -import { enumInsteadOfBooleanRule } from "../../src/rules/enum-instead-of-boolean.js"; +import { useEnumInsteadOfBooleanRule } from "../../src/rules/use-enum-instead-of-boolean.js"; let tester: LinterRuleTester; @@ -9,7 +9,7 @@ beforeEach(async () => { const runner = await Tester.createInstance(); tester = createLinterRuleTester( runner, - enumInsteadOfBooleanRule, + useEnumInsteadOfBooleanRule, "@azure-tools/typespec-azure-core", ); }); @@ -25,7 +25,7 @@ describe("boolean shapes should use descriptive extensible enums", () => { `, ) .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + code: "@azure-tools/typespec-azure-core/use-enum-instead-of-boolean", message: "Consider using an extensible enum instead of a boolean property so the API shape is more descriptive.", }); @@ -41,7 +41,7 @@ describe("boolean shapes should use descriptive extensible enums", () => { `, ) .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + code: "@azure-tools/typespec-azure-core/use-enum-instead-of-boolean", }); }); @@ -54,7 +54,7 @@ describe("boolean shapes should use descriptive extensible enums", () => { `, ) .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + code: "@azure-tools/typespec-azure-core/use-enum-instead-of-boolean", }); }); @@ -67,7 +67,7 @@ describe("boolean shapes should use descriptive extensible enums", () => { `, ) .toEmitDiagnostics({ - code: "@azure-tools/typespec-azure-core/enum-instead-of-boolean", + code: "@azure-tools/typespec-azure-core/use-enum-instead-of-boolean", }); }); diff --git a/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts b/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts index 0a7a0aa734..bf679e7645 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts @@ -8,7 +8,7 @@ export default { "@azure-tools/typespec-azure-core/byos": true, "@azure-tools/typespec-azure-core/casing-style": true, "@azure-tools/typespec-azure-core/composition-over-inheritance": true, - "@azure-tools/typespec-azure-core/enum-instead-of-boolean": true, + "@azure-tools/typespec-azure-core/use-enum-instead-of-boolean": true, "@azure-tools/typespec-azure-core/use-extensible-enum": true, "@azure-tools/typespec-azure-core/known-encoding": true, "@azure-tools/typespec-azure-core/long-running-polling-operation-required": true, diff --git a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts index b9864dcb36..b39f322956 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts @@ -9,7 +9,7 @@ export default { "@azure-tools/typespec-azure-core/byos": true, "@azure-tools/typespec-azure-core/casing-style": true, "@azure-tools/typespec-azure-core/composition-over-inheritance": true, - "@azure-tools/typespec-azure-core/enum-instead-of-boolean": true, + "@azure-tools/typespec-azure-core/use-enum-instead-of-boolean": true, "@azure-tools/typespec-azure-core/use-extensible-enum": true, "@azure-tools/typespec-azure-core/known-encoding": true, "@azure-tools/typespec-azure-core/long-running-polling-operation-required": true, diff --git a/website/src/content/docs/docs/libraries/azure-core/reference/linter.md b/website/src/content/docs/docs/libraries/azure-core/reference/linter.md index d3c6924204..c44db610ac 100644 --- a/website/src/content/docs/docs/libraries/azure-core/reference/linter.md +++ b/website/src/content/docs/docs/libraries/azure-core/reference/linter.md @@ -29,7 +29,7 @@ Available ruleSets: | [`@azure-tools/typespec-azure-core/byos`](../rules/byos.md) | Use the BYOS pattern recommended for Azure Services. | | [`@azure-tools/typespec-azure-core/casing-style`](../rules/casing-style.md) | Ensure proper casing style. | | [`@azure-tools/typespec-azure-core/composition-over-inheritance`](../rules/composition-over-inheritance.md) | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. | -| [`@azure-tools/typespec-azure-core/enum-instead-of-boolean`](../rules/enum-instead-of-boolean.md) | Boolean properties should use descriptive extensible enums when semantic values matter. | +| [`@azure-tools/typespec-azure-core/use-enum-instead-of-boolean`](../rules/use-enum-instead-of-boolean.md) | Boolean properties should use descriptive extensible enums when semantic values matter. | | [`@azure-tools/typespec-azure-core/known-encoding`](../rules/known-encoding.md) | Check for supported encodings. | | [`@azure-tools/typespec-azure-core/long-running-polling-operation-required`](../rules/long-running-polling-operation-required.md) | Long-running operations should have a linked polling operation. | | [`@azure-tools/typespec-azure-core/no-case-mismatch`](../rules/no-case-mismatch.md) | Validate that no two types have the same name with different casing. | From 6237005c825f26ac0f63dda3ffff4ab849fb46fc Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 21 Aug 2026 14:09:31 +0800 Subject: [PATCH 3/3] Link enum boolean lint provenance Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ed00e6d-dd0a-40f7-8871-ee32f0f371fb --- .../src/rules/use-enum-instead-of-boolean.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md b/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md index 16a0e00a78..24c719fc66 100644 --- a/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md +++ b/packages/typespec-azure-core/src/rules/use-enum-instead-of-boolean.md @@ -19,7 +19,8 @@ API later needs more than two values. ## LintDiff Equivalent -This rule corresponds to the LintDiff rule `EnumInsteadOfBoolean`. +This rule corresponds to the LintDiff rule +[EnumInsteadOfBoolean](https://github.com/Azure/azure-openapi-validator/blob/main/docs/enum-instead-of-boolean.md). #### Incorrect