Skip to content

Commit

Permalink
Create arm-resourceNamePatternRule-2024-2-4-21-52-56.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Mar 5, 2024
1 parent db31cda commit 65a18db
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
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-resource-manager"
---

ARM: add `arm-resource-name-pattern` rule to allow disabling LintDiff `ResourceNamePattern` rule
2 changes: 1 addition & 1 deletion packages/typespec-azure-resource-manager/src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { invalidActionVerbRule } from "./rules/arm-resource-invalid-action-verb.
import { armResourceEnvelopeProperties } from "./rules/arm-resource-invalid-envelope-property.js";
import { armResourceInvalidVersionFormatRule } from "./rules/arm-resource-invalid-version-format.js";
import { armResourceKeyInvalidCharsRule } from "./rules/arm-resource-key-invalid-chars.js";
import { armResourceNamePatternRule } from "./rules/arm-resource-name-pattern.js";
import { armResourceOperationsRule } from "./rules/arm-resource-operation-response.js";
import { patchOperationsRule } from "./rules/arm-resource-patch.js";
import { armResourcePathInvalidCharsRule } from "./rules/arm-resource-path-invalid-chars.js";
Expand All @@ -25,7 +26,6 @@ import { patchEnvelopePropertiesRules } from "./rules/patch-envelope-properties.
import { resourceNameRule } from "./rules/resource-name.js";
import { retryAfterRule } from "./rules/retry-after.js";
import { unsupportedTypeRule } from "./rules/unsupported-type.js";
import { armResourceNamePatternRule } from "./rules/arm-resource-name-pattern.js";

const rules = [
armNoRecordRule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Program, createRule } from "@typespec/compiler";

import { getLroMetadata } from "@azure-tools/typespec-azure-core";
import { getHttpOperation } from "@typespec/http";
import { getArmResources } from "../resource.js";

/**
Expand All @@ -25,7 +24,7 @@ export const armDeleteResponseCodesRule = createRule({
const deleteOperation = resource.operations.lifecycle.delete;
const isAsync =
getLroMetadata(context.program, deleteOperation.operation) !== undefined;
const [httpOp, _] = getHttpOperation(context.program, deleteOperation.operation);
const httpOp = deleteOperation.httpOperation;
const statusCodes = new Set([...httpOp.responses.map((r) => r.statusCodes.toString())]);
const expected = new Set(["204", "*"]);
expected.add(isAsync ? "202" : "200");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
createLinterRuleTester,
} from "@typespec/compiler/testing";
import { beforeEach, it } from "vitest";
import { createAzureResourceManagerTestRunner } from "../test-host.js";
import { armResourceNamePatternRule } from "../../src/rules/arm-resource-name-pattern.js";
import { createAzureResourceManagerTestRunner } from "../test-host.js";

let runner: BasicTestRunner;
let tester: LinterRuleTester;
Expand Down Expand Up @@ -56,6 +56,7 @@ it("Does not emit a warning for an ARM resource that specifies `@pattern` on the
@path
@segment("employees")
name: string;
}`)
}`
)
.toBeValid();
});

0 comments on commit 65a18db

Please sign in to comment.