From 56d1169f11f9ead8fba50cbc2c499d6237b9413d Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 18 May 2021 23:51:57 -0400 Subject: [PATCH] Added converter for react-no-dangerous-html --- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../ruleConverters/react-no-dangerous-html.ts | 12 ++++++++++++ .../tests/react-no-dangerous-html.test.ts | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/react-no-dangerous-html.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/tests/react-no-dangerous-html.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 093edb285..004cddb55 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -124,6 +124,7 @@ import { convertPreferTemplate } from "./ruleConverters/prefer-template"; import { convertPromiseFunctionAsync } from "./ruleConverters/promise-function-async"; import { convertQuotemark } from "./ruleConverters/quotemark"; import { convertRadix } from "./ruleConverters/radix"; +import { convertReactNoDangerousHtml } from "./ruleConverters/react-no-dangerous-html"; import { convertRestrictPlusOperands } from "./ruleConverters/restrict-plus-operands"; import { convertSemicolon } from "./ruleConverters/semicolon"; import { convertSpaceBeforeFunctionParen } from "./ruleConverters/space-before-function-paren"; @@ -391,6 +392,7 @@ export const ruleConverters = new Map([ ["promise-function-async", convertPromiseFunctionAsync], ["quotemark", convertQuotemark], ["radix", convertRadix], + ["react-no-dangerous-html", convertReactNoDangerousHtml], ["relative-url-prefix", convertRelativeUrlPrefix], ["restrict-plus-operands", convertRestrictPlusOperands], ["semicolon", convertSemicolon], diff --git a/src/converters/lintConfigs/rules/ruleConverters/react-no-dangerous-html.ts b/src/converters/lintConfigs/rules/ruleConverters/react-no-dangerous-html.ts new file mode 100644 index 000000000..e5603e996 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/react-no-dangerous-html.ts @@ -0,0 +1,12 @@ +import { RuleConverter } from "../ruleConverter"; + +export const convertReactNoDangerousHtml: RuleConverter = () => { + return { + plugins: ['eslint-plugin-react'], + rules: [ + { + ruleName: "react/no-danger", + }, + ], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/react-no-dangerous-html.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/react-no-dangerous-html.test.ts new file mode 100644 index 000000000..d005590fa --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/react-no-dangerous-html.test.ts @@ -0,0 +1,18 @@ +import { convertReactNoDangerousHtml } from "../react-no-dangerous-html"; + +describe(convertReactNoDangerousHtml, () => { + test("conversion without arguments", () => { + const result = convertReactNoDangerousHtml({ + ruleArguments: [], + }); + + expect(result).toEqual({ + plugins: ['eslint-plugin-react'], + rules: [ + { + ruleName: "react/no-danger", + }, + ], + }); + }); +});