Skip to content

Commit

Permalink
Remove non relevant linter rules (#707)
Browse files Browse the repository at this point in the history
All rules about the previous state of `@fixed` and open enums
- no `@fixed` - we should deprecate it as its a noop
- no fixed enum discriminator - new rule taking over recommending unions
#693

---------

Co-authored-by: Mark Cowlishaw <[email protected]>
  • Loading branch information
timotheeguerin and markcowl authored May 16, 2024
1 parent 4500461 commit 423469b
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 290 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: internal
packages:
- "@azure-tools/typespec-azure-resource-manager"
---
Doc change
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: feature
packages:
- "@azure-tools/typespec-azure-core"
---

Remove linter rules that are not relevant anymore: `use-extensible-enum` and `no-fixed-enum-discriminator`
2 changes: 0 additions & 2 deletions docs/libraries/azure-core/reference/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ Available ruleSets:
| `@azure-tools/typespec-azure-core/byos` | Use the BYOS pattern recommended for Azure Services. |
| `@azure-tools/typespec-azure-core/casing-style` | Ensure proper casing style. |
| `@azure-tools/typespec-azure-core/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/use-extensible-enum` | Enums should be extensible. |
| `@azure-tools/typespec-azure-core/known-encoding` | Check for supported encodings. |
| `@azure-tools/typespec-azure-core/long-running-polling-operation-required` | Long-running operations should have a linked polling operation. |
| [`@azure-tools/typespec-azure-core/no-closed-literal-union`](/libraries/azure-core/rules/no-closed-literal-union.md) | Unions of literals should include the base scalar type to mark them as open enum. |
| [`@azure-tools/typespec-azure-core/no-enum`](/libraries/azure-core/rules/no-enum.md) | Azure services should not use enums. |
| `@azure-tools/typespec-azure-core/no-error-status-codes` | Recommend using the error response defined by Azure REST API guidelines. |
| `@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops` | The @route decorator should not be used on standard resource operation signatures. |
| `@azure-tools/typespec-azure-core/no-fixed-enum-discriminator` | Discriminator shouldn't be a fixed enum. |
| [`@azure-tools/typespec-azure-core/non-breaking-versioning`](/libraries/azure-core/rules/non-breaking-versioning.md) | Check that only backward compatible versioning change are done to a service. |
| [`@azure-tools/typespec-azure-core/no-generic-numeric`](/libraries/azure-core/rules/no-generic-numeric.md) | Don't use generic types. Use more specific types instead. |
| `@azure-tools/typespec-azure-core/no-nullable` | Use `?` for optional properties. |
Expand Down
64 changes: 32 additions & 32 deletions docs/libraries/azure-resource-manager/reference/linter.md

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions packages/typespec-azure-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ Available ruleSets:
| `@azure-tools/typespec-azure-core/byos` | Use the BYOS pattern recommended for Azure Services. |
| `@azure-tools/typespec-azure-core/casing-style` | Ensure proper casing style. |
| `@azure-tools/typespec-azure-core/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/use-extensible-enum` | Enums should be extensible. |
| `@azure-tools/typespec-azure-core/known-encoding` | Check for supported encodings. |
| `@azure-tools/typespec-azure-core/long-running-polling-operation-required` | Long-running operations should have a linked polling operation. |
| [`@azure-tools/typespec-azure-core/no-closed-literal-union`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-closed-literal-union) | Unions of literals should include the base scalar type to mark them as open enum. |
| [`@azure-tools/typespec-azure-core/no-enum`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-enum) | Azure services should not use enums. |
| `@azure-tools/typespec-azure-core/no-error-status-codes` | Recommend using the error response defined by Azure REST API guidelines. |
| `@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops` | The @route decorator should not be used on standard resource operation signatures. |
| `@azure-tools/typespec-azure-core/no-fixed-enum-discriminator` | Discriminator shouldn't be a fixed enum. |
| [`@azure-tools/typespec-azure-core/non-breaking-versioning`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/non-breaking-versioning) | Check that only backward compatible versioning change are done to a service. |
| [`@azure-tools/typespec-azure-core/no-generic-numeric`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-generic-numeric) | Don't use generic types. Use more specific types instead. |
| `@azure-tools/typespec-azure-core/no-nullable` | Use `?` for optional properties. |
Expand Down
6 changes: 0 additions & 6 deletions packages/typespec-azure-core/src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { authRequiredRule } from "./rules/auth-required.js";
import { byosRule } from "./rules/byos.js";
import { casingRule } from "./rules/casing.js";
import { compositionOverInheritanceRule } from "./rules/composition-over-inheritance.js";
import { extensibleEnumRule } from "./rules/extensible-enums.js";
import { friendlyNameRule } from "./rules/friendly-name.js";
import { knownEncodingRule } from "./rules/known-encoding.js";
import { longRunningOperationsRequirePollingOperation } from "./rules/lro-polling-operation.js";
import { noClosedLiteralUnionRule } from "./rules/no-closed-literal-union.js";
import { noEnumRule } from "./rules/no-enum.js";
import { noErrorStatusCodesRule } from "./rules/no-error-status-codes.js";
import { noExplicitRoutesResourceOps } from "./rules/no-explicit-routes-resource-ops.js";
import { noFixedEnumDiscriminatorRule } from "./rules/no-fixed-enum-discriminator.js";
import { noGenericNumericRule } from "./rules/no-generic-numeric.js";
import { noNullableRule } from "./rules/no-nullable.js";
import { noOffsetDateTimeRule } from "./rules/no-offsetdatetime.js";
Expand Down Expand Up @@ -43,14 +41,12 @@ const rules = [
byosRule,
casingRule,
compositionOverInheritanceRule,
extensibleEnumRule,
knownEncodingRule,
longRunningOperationsRequirePollingOperation,
noClosedLiteralUnionRule,
noEnumRule,
noErrorStatusCodesRule,
noExplicitRoutesResourceOps,
noFixedEnumDiscriminatorRule,
nonBreakingVersioningRule,
noGenericNumericRule,
noNullableRule,
Expand Down Expand Up @@ -88,11 +84,9 @@ export const $linter = defineLinter({
[`@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/${extensibleEnumRule.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/${noFixedEnumDiscriminatorRule.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,
Expand Down
22 changes: 0 additions & 22 deletions packages/typespec-azure-core/src/rules/extensible-enums.ts

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions packages/typespec-azure-core/test/decorators.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Enum, Interface, Model, Operation } from "@typespec/compiler";
import {
BasicTestRunner,
LinterRuleTester,
createLinterRuleTester,
expectDiagnosticEmpty,
expectDiagnostics,
} from "@typespec/compiler/testing";
Expand All @@ -15,16 +13,13 @@ import {
getPagedResult,
isFixed,
} from "../src/decorators.js";
import { extensibleEnumRule } from "../src/rules/extensible-enums.js";
import { createAzureCoreTestRunner } from "./test-host.js";

describe("typespec-azure-core: decorators", () => {
let runner: BasicTestRunner;
let tester: LinterRuleTester;

beforeEach(async () => {
runner = await createAzureCoreTestRunner();
tester = createLinterRuleTester(runner, extensibleEnumRule, "@azure-tools/typespec-azure-core");
});

describe("@pagedResult", () => {
Expand Down Expand Up @@ -802,25 +797,6 @@ describe("typespec-azure-core: decorators", () => {
});

describe("@fixed", () => {
it("issues warning for `@fixed` enum", async () => {
await tester
.expect(
`
@test @fixed enum FixedEnum {
A,
B,
C,
}
`
)
.toEmitDiagnostics([
{
code: "@azure-tools/typespec-azure-core/use-extensible-enum",
message: "Enums should be defined without the `@fixed` decorator.",
},
]);
});

it("marks `@fixed` enum correctly", async () => {
const result = await runner.compile(
`
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 423469b

Please sign in to comment.