Skip to content

Commit

Permalink
Merge pull request #3613 from wanlwanl/wanl/adapt-new-rules-to-old-rules
Browse files Browse the repository at this point in the history
adapt new rules to old rules
  • Loading branch information
wanlwanl authored Jan 24, 2025
2 parents c02bb24 + 01ec98c commit 8d0e2cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions eng/tools/eslint-plugin-tsv/src/index.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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 '-<word>' segments. Each segment can contains letters, digits, or underscores",
condition: (_: TypeSpecConfig, _1: Rule.RuleContext) => true,
Expand All @@ -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),
Expand Down Expand Up @@ -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,
},
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion eng/tools/eslint-plugin-tsv/src/utils/rule-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
};
}

Expand Down
2 changes: 1 addition & 1 deletion eng/tools/eslint-plugin-tsv/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 8d0e2cf

Please sign in to comment.