From 45b425fe0b717b4121efc90109aa24a1d5dba7f0 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Jul 2024 10:53:21 -0700 Subject: [PATCH] Remove `all` rulesets (#927) fix [#330](https://github.com/Azure/typespec-azure/issues/330) `all` rulesets are automaticlaly provided by the compiler now https://github.com/microsoft/typespec/pull/3462 --------- Co-authored-by: Mark Cowlishaw --- .../no-all-rulsets-2024-4-28-17-4-14.md | 9 ++++ .../no-all-rulsets-2024-6-12-17-41-40.md | 8 ++++ docs/libraries/azure-core/reference/linter.md | 1 + packages/typespec-azure-core/README.md | 1 + packages/typespec-azure-core/src/linter.ts | 42 +------------------ .../src/linter.ts | 19 --------- .../src/rulesets/data-plane.ts | 3 ++ .../src/rulesets/resource-manager.ts | 3 ++ 8 files changed, 27 insertions(+), 59 deletions(-) create mode 100644 .chronus/changes/no-all-rulsets-2024-4-28-17-4-14.md create mode 100644 .chronus/changes/no-all-rulsets-2024-6-12-17-41-40.md diff --git a/.chronus/changes/no-all-rulsets-2024-4-28-17-4-14.md b/.chronus/changes/no-all-rulsets-2024-4-28-17-4-14.md new file mode 100644 index 0000000000..7c0790c52d --- /dev/null +++ b/.chronus/changes/no-all-rulsets-2024-4-28-17-4-14.md @@ -0,0 +1,9 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-azure-core" + - "@azure-tools/typespec-azure-resource-manager" +--- + +Remove explicit `all` rulesets diff --git a/.chronus/changes/no-all-rulsets-2024-6-12-17-41-40.md b/.chronus/changes/no-all-rulsets-2024-6-12-17-41-40.md new file mode 100644 index 0000000000..bbfa5d5e75 --- /dev/null +++ b/.chronus/changes/no-all-rulsets-2024-6-12-17-41-40.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-azure-rulesets" +--- + +Add rule `@azure-tools/typespec-azure-core/friendly-name` to `data-plane` and `resource-manager` rulesets diff --git a/docs/libraries/azure-core/reference/linter.md b/docs/libraries/azure-core/reference/linter.md index 26dcc26d18..f3471b65e8 100644 --- a/docs/libraries/azure-core/reference/linter.md +++ b/docs/libraries/azure-core/reference/linter.md @@ -61,3 +61,4 @@ Available ruleSets: | `@azure-tools/typespec-azure-core/use-standard-names` | Use recommended names for operations. | | `@azure-tools/typespec-azure-core/use-standard-operations` | Operations should be defined using a signature from the Azure.Core namespace. | | [`@azure-tools/typespec-azure-core/no-string-discriminator`](/libraries/azure-core/rules/no-string-discriminator.md) | Azure services discriminated models should define the discriminated property as an extensible union. | +| `@azure-tools/typespec-azure-core/friendly-name` | Ensures that @friendlyName is used as intended. | diff --git a/packages/typespec-azure-core/README.md b/packages/typespec-azure-core/README.md index bf19105d4b..f31e7fe7b9 100644 --- a/packages/typespec-azure-core/README.md +++ b/packages/typespec-azure-core/README.md @@ -65,6 +65,7 @@ Available ruleSets: | `@azure-tools/typespec-azure-core/use-standard-names` | Use recommended names for operations. | | `@azure-tools/typespec-azure-core/use-standard-operations` | Operations should be defined using a signature from the Azure.Core namespace. | | [`@azure-tools/typespec-azure-core/no-string-discriminator`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-string-discriminator) | Azure services discriminated models should define the discriminated property as an extensible union. | +| `@azure-tools/typespec-azure-core/friendly-name` | Ensures that @friendlyName is used as intended. | ## Decorators diff --git a/packages/typespec-azure-core/src/linter.ts b/packages/typespec-azure-core/src/linter.ts index 5a0bdf75a0..179a84a2bf 100644 --- a/packages/typespec-azure-core/src/linter.ts +++ b/packages/typespec-azure-core/src/linter.ts @@ -70,53 +70,15 @@ const rules = [ useStandardNames, useStandardOperations, noStringDiscriminatorRule, + friendlyNameRule, ]; export const $linter = defineLinter({ rules, ruleSets: { - all: { - enable: { - [`@azure-tools/typespec-azure-core/${apiVersionRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${authRequiredRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${operationIdRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${bodyArrayRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${byosRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${casingRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${compositionOverInheritanceRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${spreadDiscriminatedModelRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${preferCsvCollectionFormatRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${knownEncodingRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${useStandardOperations.name}`]: true, - [`@azure-tools/typespec-azure-core/${noErrorStatusCodesRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noNullableRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noOffsetDateTimeRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noRpcPathParamsRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noExplicitRoutesResourceOps.name}`]: true, - [`@azure-tools/typespec-azure-core/${noResponseBodyRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${preventFormatUse.name}`]: true, - [`@azure-tools/typespec-azure-core/${preventMultipleDiscriminator.name}`]: true, - [`@azure-tools/typespec-azure-core/${preventRestLibraryInterfaces.name}`]: true, - [`@azure-tools/typespec-azure-core/${preventUnknownType.name}`]: true, - [`@azure-tools/typespec-azure-core/${recordTypeRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${responseSchemaMultiStatusCodeRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${propertyNameRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${rpcOperationRequestBodyRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${requireDocumentation.name}`]: true, - [`@azure-tools/typespec-azure-core/${requireKeyVisibility.name}`]: true, - [`@azure-tools/typespec-azure-core/${longRunningOperationsRequirePollingOperation.name}`]: - true, - [`@azure-tools/typespec-azure-core/${useStandardNames.name}`]: true, - [`@azure-tools/typespec-azure-core/${friendlyNameRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noEnumRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noClosedLiteralUnionRule.name}`]: true, - [`@azure-tools/typespec-azure-core/${noStringDiscriminatorRule.name}`]: true, - }, - extends: ["@typespec/http/all"], - }, "canonical-versioning": { enable: { - [`@azure-tools/typespec-azure-core/${nonBreakingVersioningRule.name}`]: false, + [`@azure-tools/typespec-azure-core/${nonBreakingVersioningRule.name}`]: true, }, }, }, diff --git a/packages/typespec-azure-resource-manager/src/linter.ts b/packages/typespec-azure-resource-manager/src/linter.ts index af7feb58b0..4fedfbd018 100644 --- a/packages/typespec-azure-resource-manager/src/linter.ts +++ b/packages/typespec-azure-resource-manager/src/linter.ts @@ -63,25 +63,6 @@ const rules = [ unsupportedTypeRule, ]; -const allRulesEnabled = Object.fromEntries( - rules.map((rule) => [`@azure-tools/typespec-azure-resource-manager/${rule.name}`, true]) -); - export const $linter = defineLinter({ rules, - ruleSets: { - all: { - extends: [ - "@azure-tools/typespec-azure-core/all", - "@azure-tools/typespec-azure-core/canonical-versioning", - ], - enable: { - ...allRulesEnabled, - }, - disable: { - [`@azure-tools/typespec-azure-core/bad-record-type`]: - "This clashes with the ARM `no-record` rule.", - }, - }, - }, }); diff --git a/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts b/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts index afc99a3e7e..beafe10177 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/data-plane.ts @@ -38,6 +38,9 @@ export default { "@azure-tools/typespec-azure-core/use-standard-operations": true, "@azure-tools/typespec-azure-core/no-string-discriminator": true, + // Rules to enable later https://github.com/Azure/typespec-azure/issues/1171 + "@azure-tools/typespec-azure-core/friendly-name": false, + // Azure core rules enabled via an optional rulesets "@azure-tools/typespec-azure-core/non-breaking-versioning": false, }, diff --git a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts index 50cf483e2a..51ecb1d419 100644 --- a/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts +++ b/packages/typespec-azure-rulesets/src/rulesets/resource-manager.ts @@ -38,6 +38,9 @@ export default { "@azure-tools/typespec-azure-core/use-standard-operations": true, "@azure-tools/typespec-azure-core/no-string-discriminator": true, + // Rules to enable later https://github.com/Azure/typespec-azure/issues/1171 + "@azure-tools/typespec-azure-core/friendly-name": false, + // Azure core not enabled - Arm has its own conflicting rule "@azure-tools/typespec-azure-core/bad-record-type": false,