Skip to content

Update typespec validation rules #34624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { join } from "path";
import { parse as yamlParse } from "yaml";
import { Rule } from "../rule.js";
Expand Down Expand Up @@ -192,6 +192,34 @@
}
}

export class TspConfigJavaMgmtPackageDirFormatSubRule extends TspconfigEmitterOptionsSubRuleBase {
constructor() {
super(
"@azure-tools/typespec-java",
"package-dir",
new RegExp(/^azure-resourcemanager-[^\/]+$/) // Matches "azure-resourcemanager-<service-name>" with no restriction on characters after the hyphen
);
}

protected skip(_: any, folder: string) {
return skipForDataPlane(folder); // Ensures this rule only applies to management plane SDKs
}
}

export class TspConfigJavaMgmtNamespaceFormatSubRule extends TspconfigEmitterOptionsSubRuleBase {
constructor() {
super(
"@azure-tools/typespec-java",
"namespace",
new RegExp(/^com\.azure\.resourcemanager\.[^\.]+$/) // Matches "com.azure.resourcemanager.<service-name>" with no restriction on characters after the last dot
);
}

protected skip(_: any, folder: string) {
return skipForDataPlane(folder); // Ensures this rule only applies to management plane SDKs
}
}

// ----- TS management modular sub rules -----
export class TspConfigTsMgmtModularExperimentalExtensibleEnumsTrueSubRule extends TspconfigEmitterOptionsSubRuleBase {
constructor() {
Expand All @@ -204,10 +232,15 @@

export class TspConfigTsMgmtModularPackageDirectorySubRule extends TspconfigEmitterOptionsSubRuleBase {
constructor() {
super("@azure-tools/typespec-ts", "package-dir", new RegExp(/^arm(?:-[a-z]+)+$/));
super(
"@azure-tools/typespec-ts",
"package-dir",
new RegExp(/^arm-[^\/]+$/)
);
}

protected skip(config: any, folder: string) {
return skipForNonModularOrDataPlaneInTsEmitter(config, folder);
return skipForNonModularOrDataPlaneInTsEmitter(config, folder);
}
}

Expand Down Expand Up @@ -284,6 +317,7 @@
}
}

// ----- Go Mgmt plane sub rules -----
export class TspConfigGoMgmtServiceDirMatchPatternSubRule extends TspconfigEmitterOptionsSubRuleBase {
constructor() {
super("@azure-tools/typespec-go", "service-dir", new RegExp(/^sdk\/resourcemanager\/[^\/]*$/));
Expand Down Expand Up @@ -451,6 +485,8 @@
export const defaultRules = [
new TspConfigCommonAzServiceDirMatchPatternSubRule(),
new TspConfigJavaAzPackageDirectorySubRule(),
new TspConfigJavaMgmtPackageDirFormatSubRule(),
new TspConfigJavaMgmtNamespaceFormatSubRule(),
new TspConfigTsMgmtModularExperimentalExtensibleEnumsTrueSubRule(),
new TspConfigTsMgmtModularPackageDirectorySubRule(),
new TspConfigTsMgmtModularPackageNameMatchPatternSubRule(),
Expand Down
Loading