From a011fdfd6181d80c24277f43c528ad9f4ed04b27 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 3 Jul 2021 14:36:20 -0400 Subject: [PATCH] Manually correct 'a11y' in newConverter script (#1139) --- script/newConverter/index.js | 2 +- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../rules/ruleConverters/react-a11y-lang.ts | 12 ++++++++++++ .../tests/react-a11y-lang.test.ts | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/react-a11y-lang.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/tests/react-a11y-lang.test.ts diff --git a/script/newConverter/index.js b/script/newConverter/index.js index ba1f9eb48..4061a908d 100644 --- a/script/newConverter/index.js +++ b/script/newConverter/index.js @@ -19,7 +19,7 @@ const { writeConverterTest } = require("./writeConverterTest"); } } - const tslintPascalCase = upperFirst(camelCase(args.tslint)); + const tslintPascalCase = upperFirst(camelCase(args.tslint)).replace("A11Y", "A11y"); const plugins = args.eslint.includes("/") ? ` plugins: ["${args.eslint.split("/")[0]}"],` diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index d91f13f94..1b3d3e00d 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -253,6 +253,7 @@ import { convertQuotemark } from "./ruleConverters/quotemark"; import { convertRadix } from "./ruleConverters/radix"; import { convertReactA11yAccessibleHeadings } from "./ruleConverters/react-a11y-accessible-headings"; import { convertReactA11yAnchors } from "./ruleConverters/react-a11y-anchors"; +import { convertReactA11yLang } from "./ruleConverters/react-a11y-lang"; import { convertReactNoDangerousHtml } from "./ruleConverters/react-no-dangerous-html"; import { convertReactTsxCurlySpacing } from "./ruleConverters/react-tsx-curly-spacing"; import { convertRestrictPlusOperands } from "./ruleConverters/restrict-plus-operands"; @@ -488,6 +489,7 @@ export const ruleConverters = new Map([ ["quotemark", convertQuotemark], ["radix", convertRadix], ["react-a11y-anchors", convertReactA11yAnchors], + ["react-a11y-lang", convertReactA11yLang], ["react-no-dangerous-html", convertReactNoDangerousHtml], ["react-tsx-curly-spacing", convertReactTsxCurlySpacing], ["relative-url-prefix", convertRelativeUrlPrefix], diff --git a/src/converters/lintConfigs/rules/ruleConverters/react-a11y-lang.ts b/src/converters/lintConfigs/rules/ruleConverters/react-a11y-lang.ts new file mode 100644 index 000000000..04a651030 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/react-a11y-lang.ts @@ -0,0 +1,12 @@ +import { RuleConverter } from "../ruleConverter"; + +export const convertReactA11yLang: RuleConverter = () => { + return { + plugins: ["jsx-a11y"], + rules: [ + { + ruleName: "jsx-a11y/lang", + }, + ], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/react-a11y-lang.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/react-a11y-lang.test.ts new file mode 100644 index 000000000..c66211388 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/react-a11y-lang.test.ts @@ -0,0 +1,18 @@ +import { convertReactA11yLang } from "../react-a11y-lang"; + +describe(convertReactA11yLang, () => { + test("conversion without arguments", () => { + const result = convertReactA11yLang({ + ruleArguments: [], + }); + + expect(result).toEqual({ + plugins: ["jsx-a11y"], + rules: [ + { + ruleName: "jsx-a11y/lang", + }, + ], + }); + }); +});