feat: support tslint rule references
MODIFY
scripts/generated-files/lint-rules-docs.ts
scripts/generated-files/lint-rules-docs.ts
@@ -40,15 +40,16 @@ function highlightPre(filename: string, code: string): string {
}
// Extract the description field from the docs frontmatter
-export function extractESLintRuleInfo(
+export function extractLintRuleInfo(
content: string,
+ type: "eslint" | "tslint" = "eslint",
):
| undefined
| {
url: string;
name: string;
} {
- const match = content.match(/eslint-rule:(.*)(\n|\r\n)/);
+ const match = content.match(new RegExp(`${type}-rule:(.*)(\n|\r\n)`));
if (match) {
const url = match[1].trim();
@@ -130,7 +131,8 @@ export async function main() {
},
async () => {
const content = await readFileText(docs);
- const eslintInfo = extractESLintRuleInfo(content);
+ const eslintInfo = extractLintRuleInfo(content, "eslint");
+ const tslintInfo = extractLintRuleInfo(content, "tslint");
const lines = [];
@@ -145,6 +147,12 @@ export async function main() {
);
}
+ if (tslintInfo !== undefined) {
+ lines.push(
+ `**TSLint Equivalent:** [${tslintInfo.name}](${tslintInfo.url})`,
+ );
+ }
+
return {lines};
},
);

feat: support tslint rule references (#1150)