Skip to content

Commit

Permalink
Remove all rulesets (#927)
Browse files Browse the repository at this point in the history
fix [#330](#330)

`all` rulesets are automaticlaly provided by the compiler now
microsoft/typespec#3462

---------

Co-authored-by: Mark Cowlishaw <[email protected]>
  • Loading branch information
timotheeguerin and markcowl authored Jul 16, 2024
1 parent bbb3d19 commit 45b425f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 59 deletions.
9 changes: 9 additions & 0 deletions .chronus/changes/no-all-rulsets-2024-4-28-17-4-14.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .chronus/changes/no-all-rulsets-2024-6-12-17-41-40.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/libraries/azure-core/reference/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
1 change: 1 addition & 0 deletions packages/typespec-azure-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
42 changes: 2 additions & 40 deletions packages/typespec-azure-core/src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down
19 changes: 0 additions & 19 deletions packages/typespec-azure-resource-manager/src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
},
},
});
3 changes: 3 additions & 0 deletions packages/typespec-azure-rulesets/src/rulesets/data-plane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit 45b425f

Please sign in to comment.