From 8550e880f86a711cbf86eb77ecc1c66d3bedd4ab Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Fri, 24 Jan 2025 17:44:07 +0800 Subject: [PATCH 1/4] update --- eng/tools/eslint-plugin-tsv/package.json | 2 +- eng/tools/eslint-plugin-tsv/test/e2e.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/tools/eslint-plugin-tsv/package.json b/eng/tools/eslint-plugin-tsv/package.json index b124f469f81f..5c8ca554c3b7 100644 --- a/eng/tools/eslint-plugin-tsv/package.json +++ b/eng/tools/eslint-plugin-tsv/package.json @@ -2,7 +2,7 @@ "name": "@azure-tools/eslint-plugin-tsv", "private": true, "type": "module", - "main": "src/index.js", + "main": "dist/src/index.js", "dependencies": { "ajv": "^8.17.1", "yaml-eslint-parser": "^1.2.3" diff --git a/eng/tools/eslint-plugin-tsv/test/e2e.test.ts b/eng/tools/eslint-plugin-tsv/test/e2e.test.ts index e6da7e107a9d..7c8ed1376584 100644 --- a/eng/tools/eslint-plugin-tsv/test/e2e.test.ts +++ b/eng/tools/eslint-plugin-tsv/test/e2e.test.ts @@ -5,7 +5,7 @@ import eslintPluginTsv from "../src/eslint-plugin-tsv.js"; function createESLint() { return new ESLint({ - cwd: join(__dirname, "../../../../"), + cwd: "/", overrideConfig: eslintPluginTsv.configs.recommended, overrideConfigFile: true, }); From 71fec2e9eaae2949f471534da029165f1ab32cbf Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Fri, 24 Jan 2025 17:49:09 +0800 Subject: [PATCH 2/4] improve placeholder --- .../src/rules/tspconfig-validation-rules.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/eng/tools/eslint-plugin-tsv/src/rules/tspconfig-validation-rules.ts b/eng/tools/eslint-plugin-tsv/src/rules/tspconfig-validation-rules.ts index 83f193b825f7..9eae374011e1 100644 --- a/eng/tools/eslint-plugin-tsv/src/rules/tspconfig-validation-rules.ts +++ b/eng/tools/eslint-plugin-tsv/src/rules/tspconfig-validation-rules.ts @@ -19,7 +19,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "service-dir", type: KeyType.Parameter, expectedValue: /^sdk\/[^\/]*$/, - exampleValue: "sdk/aaa", + exampleValue: "sdk/placeholder", extraExplanation: "The 'service-dir' should be a string that starts with 'sdk/', followed by zero or more characters that are not a '/', and ends there", condition: (_: TypeSpecConfig, _1: Rule.RuleContext) => true, @@ -62,7 +62,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "package-dir", type: KeyType.EmitterOption, expectedValue: /^arm(?:-[a-z]+)+$/, - exampleValue: "arm-aaa-bbb", + exampleValue: "arm-placeholder-placeholder", extraExplanation: "The 'package-dir' should be a string that starts with 'arm' and is followed by one or more groups of a hyphen (-) and lowercase letters", condition: tsIsManagementCondition, @@ -72,7 +72,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "packageDetails.name", type: KeyType.EmitterOption, expectedValue: /^\@azure\/arm(?:-[a-z]+)+$/, - exampleValue: "@azure/arm-aaa-bbb", + exampleValue: "@azure/arm-placeholder-placeholder", extraExplanation: "The package name should be a string that starts with '@azure/arm' and is followed by one or more groups of a hyphen (-) and lowercase letters", condition: tsIsManagementCondition, @@ -83,7 +83,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "service-dir", type: KeyType.EmitterOption, expectedValue: /^sdk\/resourcemanager\/[^\/]*$/, - exampleValue: "sdk/resourcemanager/aaa", + exampleValue: "sdk/resourcemanager/placeholder", extraExplanation: "The 'service-dir' should be a string that starts with 'sdk/resourcemanager/', followed by zero or more characters that are not a '/', and ends there", condition: (_: TypeSpecConfig, context: Rule.RuleContext) => isManagementSDK(context), @@ -93,7 +93,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "package-dir", type: KeyType.EmitterOption, expectedValue: /^arm[^\/]*$/, - exampleValue: "armaaa", + exampleValue: "armplaceholder", extraExplanation: "The 'package-dir' should be a string that starts with 'arm' and do not contain a forward slash (/) after it", condition: (_: TypeSpecConfig, context: Rule.RuleContext) => isManagementSDK(context), @@ -152,7 +152,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "package-dir", type: KeyType.EmitterOption, expectedValue: /^azure(-\w+)+$/, - exampleValue: "azure-aaa", + exampleValue: "azure-placeholder", extraExplanation: "The 'package-dir' should be a string that starts with 'azure', followed by one or more '-' segments. Each segment can contains letters, digits, or underscores", condition: (_: TypeSpecConfig, _1: Rule.RuleContext) => true, @@ -163,7 +163,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "package-dir", type: KeyType.EmitterOption, expectedValue: /^azure-mgmt(-[a-z]+){1,2}$/, - exampleValue: "azure-mgmt-aaa", + exampleValue: "azure-mgmt-placeholder", extraExplanation: "The 'package-dir' should be a string that starts with 'azure-mgmt', followed by 1 or 2 hyphen-separated lowercase alphabetic segments", condition: (_: TypeSpecConfig, context: Rule.RuleContext) => isManagementSDK(context), @@ -198,7 +198,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "package-dir", type: KeyType.EmitterOption, expectedValue: /^Azure\./, - exampleValue: "Azure.aaa", + exampleValue: "Azure.placeholder", extraExplanation: "The 'package-dir' should be a string that starts with 'Azure.'", condition: (_: TypeSpecConfig, _1: Rule.RuleContext) => true, }, @@ -223,7 +223,7 @@ const args: CreateCodeGenSDKRuleArgs[] = [ key: "package-dir", type: KeyType.EmitterOption, expectedValue: /^Azure\.ResourceManager\./, - exampleValue: "Azure.ResourceManager.aaa", + exampleValue: "Azure.ResourceManager.Placeholder", extraExplanation: "The 'package-dir' should be a string that starts with 'Azure.ResourceManager.'", condition: (_: TypeSpecConfig, context: Rule.RuleContext) => isManagementSDK(context), From 9a378a02cfc1e9f593384f791e2dbb22889a6b10 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Fri, 24 Jan 2025 17:59:45 +0800 Subject: [PATCH 3/4] improve message --- eng/tools/eslint-plugin-tsv/package.json | 1 - eng/tools/eslint-plugin-tsv/src/utils/rule-creator.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/tools/eslint-plugin-tsv/package.json b/eng/tools/eslint-plugin-tsv/package.json index 5c8ca554c3b7..9d1d2e017739 100644 --- a/eng/tools/eslint-plugin-tsv/package.json +++ b/eng/tools/eslint-plugin-tsv/package.json @@ -2,7 +2,6 @@ "name": "@azure-tools/eslint-plugin-tsv", "private": true, "type": "module", - "main": "dist/src/index.js", "dependencies": { "ajv": "^8.17.1", "yaml-eslint-parser": "^1.2.3" diff --git a/eng/tools/eslint-plugin-tsv/src/utils/rule-creator.ts b/eng/tools/eslint-plugin-tsv/src/utils/rule-creator.ts index 5040e54b07bd..36f9571934f3 100644 --- a/eng/tools/eslint-plugin-tsv/src/utils/rule-creator.ts +++ b/eng/tools/eslint-plugin-tsv/src/utils/rule-creator.ts @@ -40,7 +40,7 @@ export function createRule(ruleContext: RuleInfo): NamedRule.RuleModule { export function createRuleMessages(messageId: string, docs: RuleDocument) { return { - [messageId]: `${docs.error}.\n${docs.action}.\n${docs.example}`, + [messageId]: `Error: ${docs.error}.\nAction: ${docs.action}.\nExample: ${docs.example}`, }; } From 01ec98c82745d35f9b5048ab3243dc8d5d44a4ee Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Fri, 24 Jan 2025 18:02:20 +0800 Subject: [PATCH 4/4] update --- eng/tools/eslint-plugin-tsv/package.json | 1 + eng/tools/eslint-plugin-tsv/src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/eng/tools/eslint-plugin-tsv/package.json b/eng/tools/eslint-plugin-tsv/package.json index 9d1d2e017739..5c8ca554c3b7 100644 --- a/eng/tools/eslint-plugin-tsv/package.json +++ b/eng/tools/eslint-plugin-tsv/package.json @@ -2,6 +2,7 @@ "name": "@azure-tools/eslint-plugin-tsv", "private": true, "type": "module", + "main": "dist/src/index.js", "dependencies": { "ajv": "^8.17.1", "yaml-eslint-parser": "^1.2.3" diff --git a/eng/tools/eslint-plugin-tsv/src/index.ts b/eng/tools/eslint-plugin-tsv/src/index.ts index 6e6e166c1421..166204f4a9e6 100644 --- a/eng/tools/eslint-plugin-tsv/src/index.ts +++ b/eng/tools/eslint-plugin-tsv/src/index.ts @@ -1,3 +1,4 @@ +// Note: This file is a tempory workaround for converting new rules to old rules import { ESLint } from "eslint"; import tsvPlugin from "./eslint-plugin-tsv.js";