From cf637e0f2cee308b8426a71583e6cc96ce7e4b08 Mon Sep 17 00:00:00 2001 From: tadelesh Date: Thu, 31 Jul 2025 13:38:23 +0800 Subject: [PATCH 1/4] Change Go rule for tspconfig.yaml --- .../src/rules/sdk-tspconfig-validation.ts | 16 +++++++++++-- .../test/sdk-tspconfig-validation.test.ts | 24 ++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts b/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts index 40961fcc6397..6b60a9bedc51 100644 --- a/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts +++ b/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts @@ -389,7 +389,7 @@ export class TspConfigGoMgmtModuleEqualStringSubRule extends TspconfigEmitterOpt export class TspConfigGoMgmtFixConstStutteringTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { constructor() { - super("@azure-tools/typespec-go", "fix-const-stuttering", true); + super("@azure-tools/typespec-go", "fix-const-stuttering", new RegExp(/^true|false$/)); } protected skip(_: any, folder: string) { return skipForDataPlane(folder); @@ -414,10 +414,22 @@ export class TspConfigGoMgmtHeadAsBooleanTrueSubRule extends TspconfigEmitterOpt } } +export class TspConfigGoMgmtGenerateFakesTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { + constructor() { + super("@azure-tools/typespec-go", "generate-fakes", true); + } + protected skip(_: any, folder: string) { + return skipForDataPlane(folder); + } +} + // ----- Go az sub rules ----- export class TspConfigGoAzGenerateFakesTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { constructor() { - super("@azure-tools/typespec-go", "generate-fakes", true); + super("@azure-tools/typespec-go", "generate-fakes", new RegExp(/^true|false$/)); + } + protected skip(_: any, folder: string) { + return skipForManagementPlane(folder); } } diff --git a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts index cff5a059c4fd..93abdd63ef89 100644 --- a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts +++ b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts @@ -17,6 +17,7 @@ import { TspConfigGoDpPackageDirectoryMatchPatternSubRule, TspConfigGoDpServiceDirMatchPatternSubRule, TspConfigGoMgmtFixConstStutteringTrueSubRule, + TspConfigGoMgmtGenerateFakesTrueSubRule, TspConfigGoMgmtGenerateSamplesTrueSubRule, TspConfigGoMgmtHeadAsBooleanTrueSubRule, TspConfigGoMgmtModuleEqualStringSubRule, @@ -292,7 +293,16 @@ const goManagementFixConstStutteringTestCases = createEmitterOptionTestCases( managementTspconfigFolder, "fix-const-stuttering", true, + "true", + [new TspConfigGoMgmtFixConstStutteringTrueSubRule()], +); + +const goManagementFixConstStutteringAnotherTestCases = createEmitterOptionTestCases( + "@azure-tools/typespec-go", + managementTspconfigFolder, + "fix-const-stuttering", false, + "false", [new TspConfigGoMgmtFixConstStutteringTrueSubRule()], ); @@ -311,7 +321,7 @@ const goManagementGenerateFakesTestCases = createEmitterOptionTestCases( "generate-fakes", true, false, - [new TspConfigGoAzGenerateFakesTrueSubRule()], + [new TspConfigGoMgmtGenerateFakesTrueSubRule()], ); const goDpGenerateFakesTestCases = createEmitterOptionTestCases( @@ -319,10 +329,20 @@ const goDpGenerateFakesTestCases = createEmitterOptionTestCases( "", "generate-fakes", true, + "true", + [new TspConfigGoAzGenerateFakesTrueSubRule()], +); + +const goDpGenerateFakesAnotherTestCases = createEmitterOptionTestCases( + "@azure-tools/typespec-go", + "", + "generate-fakes", false, + "false", [new TspConfigGoAzGenerateFakesTrueSubRule()], ); + const goManagementHeadAsBooleanTestCases = createEmitterOptionTestCases( "@azure-tools/typespec-go", managementTspconfigFolder, @@ -662,11 +682,13 @@ describe("tspconfig", function () { ...goManagementPackageDirTestCases, ...goManagementModuleTestCases, ...goManagementFixConstStutteringTestCases, + ...goManagementFixConstStutteringAnotherTestCases, ...goManagementGenerateExamplesTestCases, ...goManagementGenerateFakesTestCases, ...goManagementHeadAsBooleanTestCases, ...goManagementInjectSpansTestCases, ...goDpGenerateFakesTestCases, + ...goDpGenerateFakesAnotherTestCases, ...goDpInjectSpansTestCases, ...goDpModuleTestCases, ...goDpPackageDirTestCases, From df80e5d5733921b65697422ddc81154209e88315 Mon Sep 17 00:00:00 2001 From: tadelesh Date: Thu, 31 Jul 2025 13:40:46 +0800 Subject: [PATCH 2/4] rename --- .../src/rules/sdk-tspconfig-validation.ts | 9 +++++---- .../test/sdk-tspconfig-validation.test.ts | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts b/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts index 6b60a9bedc51..b71ef38a48ee 100644 --- a/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts +++ b/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts @@ -387,7 +387,7 @@ export class TspConfigGoMgmtModuleEqualStringSubRule extends TspconfigEmitterOpt } } -export class TspConfigGoMgmtFixConstStutteringTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { +export class TspConfigGoMgmtFixConstStutteringSubRule extends TspconfigEmitterOptionsSubRuleBase { constructor() { super("@azure-tools/typespec-go", "fix-const-stuttering", new RegExp(/^true|false$/)); } @@ -424,7 +424,7 @@ export class TspConfigGoMgmtGenerateFakesTrueSubRule extends TspconfigEmitterOpt } // ----- Go az sub rules ----- -export class TspConfigGoAzGenerateFakesTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { +export class TspConfigGoAzGenerateFakesSubRule extends TspconfigEmitterOptionsSubRuleBase { constructor() { super("@azure-tools/typespec-go", "generate-fakes", new RegExp(/^true|false$/)); } @@ -551,9 +551,10 @@ export const defaultRules = [ new TspConfigGoMgmtServiceDirMatchPatternSubRule(), new TspConfigGoMgmtPackageDirectorySubRule(), new TspConfigGoMgmtModuleEqualStringSubRule(), - new TspConfigGoMgmtFixConstStutteringTrueSubRule(), + new TspConfigGoMgmtFixConstStutteringSubRule(), new TspConfigGoMgmtGenerateSamplesTrueSubRule(), - new TspConfigGoAzGenerateFakesTrueSubRule(), + new TspConfigGoMgmtGenerateFakesTrueSubRule(), + new TspConfigGoAzGenerateFakesSubRule(), new TspConfigGoMgmtHeadAsBooleanTrueSubRule(), new TspConfigGoAzInjectSpansTrueSubRule(), new TspConfigGoDpServiceDirMatchPatternSubRule(), diff --git a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts index 93abdd63ef89..8a881a5fafb7 100644 --- a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts +++ b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts @@ -11,12 +11,12 @@ import { TspConfigCsharpAzNamespaceEqualStringSubRule, TspConfigCsharpAzPackageDirectorySubRule, TspConfigCsharpMgmtPackageDirectorySubRule, - TspConfigGoAzGenerateFakesTrueSubRule, + TspConfigGoAzGenerateFakesSubRule, TspConfigGoAzInjectSpansTrueSubRule, TspConfigGoDpModuleMatchPatternSubRule, TspConfigGoDpPackageDirectoryMatchPatternSubRule, TspConfigGoDpServiceDirMatchPatternSubRule, - TspConfigGoMgmtFixConstStutteringTrueSubRule, + TspConfigGoMgmtFixConstStutteringSubRule, TspConfigGoMgmtGenerateFakesTrueSubRule, TspConfigGoMgmtGenerateSamplesTrueSubRule, TspConfigGoMgmtHeadAsBooleanTrueSubRule, @@ -294,7 +294,7 @@ const goManagementFixConstStutteringTestCases = createEmitterOptionTestCases( "fix-const-stuttering", true, "true", - [new TspConfigGoMgmtFixConstStutteringTrueSubRule()], + [new TspConfigGoMgmtFixConstStutteringSubRule()], ); const goManagementFixConstStutteringAnotherTestCases = createEmitterOptionTestCases( @@ -303,7 +303,7 @@ const goManagementFixConstStutteringAnotherTestCases = createEmitterOptionTestCa "fix-const-stuttering", false, "false", - [new TspConfigGoMgmtFixConstStutteringTrueSubRule()], + [new TspConfigGoMgmtFixConstStutteringSubRule()], ); const goManagementGenerateExamplesTestCases = createEmitterOptionTestCases( @@ -330,7 +330,7 @@ const goDpGenerateFakesTestCases = createEmitterOptionTestCases( "generate-fakes", true, "true", - [new TspConfigGoAzGenerateFakesTrueSubRule()], + [new TspConfigGoAzGenerateFakesSubRule()], ); const goDpGenerateFakesAnotherTestCases = createEmitterOptionTestCases( @@ -339,7 +339,7 @@ const goDpGenerateFakesAnotherTestCases = createEmitterOptionTestCases( "generate-fakes", false, "false", - [new TspConfigGoAzGenerateFakesTrueSubRule()], + [new TspConfigGoAzGenerateFakesSubRule()], ); @@ -639,7 +639,7 @@ options: subRules: [ new TspConfigGoMgmtPackageDirectorySubRule(), new TspConfigGoMgmtModuleEqualStringSubRule(), - new TspConfigGoMgmtFixConstStutteringTrueSubRule(), + new TspConfigGoMgmtFixConstStutteringSubRule(), ], tspconfigContent: ` options: From e4dba778a08a34131fdb55f03179e9eda9130ca3 Mon Sep 17 00:00:00 2001 From: tadelesh Date: Thu, 31 Jul 2025 13:52:45 +0800 Subject: [PATCH 3/4] fix format --- .../typespec-validation/test/sdk-tspconfig-validation.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts index 8a881a5fafb7..7e5fee3e6cdc 100644 --- a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts +++ b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts @@ -342,7 +342,6 @@ const goDpGenerateFakesAnotherTestCases = createEmitterOptionTestCases( [new TspConfigGoAzGenerateFakesSubRule()], ); - const goManagementHeadAsBooleanTestCases = createEmitterOptionTestCases( "@azure-tools/typespec-go", managementTspconfigFolder, From 828b78e46ad6edb145fab5ec7dc1ebb6fc68e3f3 Mon Sep 17 00:00:00 2001 From: tadelesh Date: Thu, 31 Jul 2025 13:59:09 +0800 Subject: [PATCH 4/4] remove rules --- .../src/rules/sdk-tspconfig-validation.ts | 19 -------- .../test/sdk-tspconfig-validation.test.ts | 43 ------------------- 2 files changed, 62 deletions(-) diff --git a/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts b/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts index b71ef38a48ee..d10191bf9689 100644 --- a/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts +++ b/eng/tools/typespec-validation/src/rules/sdk-tspconfig-validation.ts @@ -387,15 +387,6 @@ export class TspConfigGoMgmtModuleEqualStringSubRule extends TspconfigEmitterOpt } } -export class TspConfigGoMgmtFixConstStutteringSubRule extends TspconfigEmitterOptionsSubRuleBase { - constructor() { - super("@azure-tools/typespec-go", "fix-const-stuttering", new RegExp(/^true|false$/)); - } - protected skip(_: any, folder: string) { - return skipForDataPlane(folder); - } -} - export class TspConfigGoMgmtGenerateSamplesTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { constructor() { super("@azure-tools/typespec-go", "generate-samples", true); @@ -424,14 +415,6 @@ export class TspConfigGoMgmtGenerateFakesTrueSubRule extends TspconfigEmitterOpt } // ----- Go az sub rules ----- -export class TspConfigGoAzGenerateFakesSubRule extends TspconfigEmitterOptionsSubRuleBase { - constructor() { - super("@azure-tools/typespec-go", "generate-fakes", new RegExp(/^true|false$/)); - } - protected skip(_: any, folder: string) { - return skipForManagementPlane(folder); - } -} export class TspConfigGoAzInjectSpansTrueSubRule extends TspconfigEmitterOptionsSubRuleBase { constructor() { @@ -551,10 +534,8 @@ export const defaultRules = [ new TspConfigGoMgmtServiceDirMatchPatternSubRule(), new TspConfigGoMgmtPackageDirectorySubRule(), new TspConfigGoMgmtModuleEqualStringSubRule(), - new TspConfigGoMgmtFixConstStutteringSubRule(), new TspConfigGoMgmtGenerateSamplesTrueSubRule(), new TspConfigGoMgmtGenerateFakesTrueSubRule(), - new TspConfigGoAzGenerateFakesSubRule(), new TspConfigGoMgmtHeadAsBooleanTrueSubRule(), new TspConfigGoAzInjectSpansTrueSubRule(), new TspConfigGoDpServiceDirMatchPatternSubRule(), diff --git a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts index 7e5fee3e6cdc..20dd12780a11 100644 --- a/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts +++ b/eng/tools/typespec-validation/test/sdk-tspconfig-validation.test.ts @@ -11,12 +11,10 @@ import { TspConfigCsharpAzNamespaceEqualStringSubRule, TspConfigCsharpAzPackageDirectorySubRule, TspConfigCsharpMgmtPackageDirectorySubRule, - TspConfigGoAzGenerateFakesSubRule, TspConfigGoAzInjectSpansTrueSubRule, TspConfigGoDpModuleMatchPatternSubRule, TspConfigGoDpPackageDirectoryMatchPatternSubRule, TspConfigGoDpServiceDirMatchPatternSubRule, - TspConfigGoMgmtFixConstStutteringSubRule, TspConfigGoMgmtGenerateFakesTrueSubRule, TspConfigGoMgmtGenerateSamplesTrueSubRule, TspConfigGoMgmtHeadAsBooleanTrueSubRule, @@ -288,24 +286,6 @@ const goManagementModuleTestCases = createEmitterOptionTestCases( [new TspConfigGoMgmtModuleEqualStringSubRule()], ); -const goManagementFixConstStutteringTestCases = createEmitterOptionTestCases( - "@azure-tools/typespec-go", - managementTspconfigFolder, - "fix-const-stuttering", - true, - "true", - [new TspConfigGoMgmtFixConstStutteringSubRule()], -); - -const goManagementFixConstStutteringAnotherTestCases = createEmitterOptionTestCases( - "@azure-tools/typespec-go", - managementTspconfigFolder, - "fix-const-stuttering", - false, - "false", - [new TspConfigGoMgmtFixConstStutteringSubRule()], -); - const goManagementGenerateExamplesTestCases = createEmitterOptionTestCases( "@azure-tools/typespec-go", managementTspconfigFolder, @@ -324,24 +304,6 @@ const goManagementGenerateFakesTestCases = createEmitterOptionTestCases( [new TspConfigGoMgmtGenerateFakesTrueSubRule()], ); -const goDpGenerateFakesTestCases = createEmitterOptionTestCases( - "@azure-tools/typespec-go", - "", - "generate-fakes", - true, - "true", - [new TspConfigGoAzGenerateFakesSubRule()], -); - -const goDpGenerateFakesAnotherTestCases = createEmitterOptionTestCases( - "@azure-tools/typespec-go", - "", - "generate-fakes", - false, - "false", - [new TspConfigGoAzGenerateFakesSubRule()], -); - const goManagementHeadAsBooleanTestCases = createEmitterOptionTestCases( "@azure-tools/typespec-go", managementTspconfigFolder, @@ -638,7 +600,6 @@ options: subRules: [ new TspConfigGoMgmtPackageDirectorySubRule(), new TspConfigGoMgmtModuleEqualStringSubRule(), - new TspConfigGoMgmtFixConstStutteringSubRule(), ], tspconfigContent: ` options: @@ -680,14 +641,10 @@ describe("tspconfig", function () { ...goManagementServiceDirTestCases, ...goManagementPackageDirTestCases, ...goManagementModuleTestCases, - ...goManagementFixConstStutteringTestCases, - ...goManagementFixConstStutteringAnotherTestCases, ...goManagementGenerateExamplesTestCases, ...goManagementGenerateFakesTestCases, ...goManagementHeadAsBooleanTestCases, ...goManagementInjectSpansTestCases, - ...goDpGenerateFakesTestCases, - ...goDpGenerateFakesAnotherTestCases, ...goDpInjectSpansTestCases, ...goDpModuleTestCases, ...goDpPackageDirTestCases,