From f364a636bd7f52661bb68028d11ce689d23455d6 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 12 Dec 2020 14:56:29 -0500 Subject: [PATCH 1/2] Added converter for jsx-self-close rule --- .../eslint-plugin-react/jsx-self-close.ts | 12 ++++++++++++ .../tests/jsx-self-close.test.ts | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-self-close.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-self-close.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-self-close.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-self-close.ts new file mode 100644 index 000000000..03ab28aff --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-self-close.ts @@ -0,0 +1,12 @@ +import { RuleConverter } from "../../ruleConverter"; + +export const convertJsxSelfClose: RuleConverter = () => { + return { + rules: [ + { + ruleName: "react/self-closing-comp", + }, + ], + plugins: ["eslint-plugin-react"], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-self-close.test.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-self-close.test.ts new file mode 100644 index 000000000..511ca2cde --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-self-close.test.ts @@ -0,0 +1,18 @@ +import { convertJsxSelfClose } from "../jsx-self-close"; + +describe(convertJsxSelfClose, () => { + test("conversion without arguments", () => { + const result = convertJsxSelfClose({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "react/self-closing-comp", + }, + ], + plugins: ["eslint-plugin-react"], + }); + }); +}); From 18e02bc37549a5fed6ff826cf22b76c32ef1a380 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 12 Dec 2020 15:00:26 -0500 Subject: [PATCH 2/2] And ruleConverters, too --- src/converters/lintConfigs/rules/ruleConverters.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 4baf906e4..ee2779794 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -181,6 +181,7 @@ import { convertJsxCurlySpacing } from "./ruleConverters/eslint-plugin-react/jsx import { convertJsxEqualsSpacing } from "./ruleConverters/eslint-plugin-react/jsx-equals-spacing"; import { convertJsxKey } from "./ruleConverters/eslint-plugin-react/jsx-key"; import { convertJsxNoBind } from "./ruleConverters/eslint-plugin-react/jsx-no-bind"; +import { convertJsxSelfClose } from "./ruleConverters/eslint-plugin-react/jsx-self-close"; import { convertJsxWrapMultiline } from "./ruleConverters/eslint-plugin-react/jsx-wrap-multiline"; // eslint-plugin-rxjs converters @@ -242,6 +243,7 @@ export const ruleConverters = new Map([ ["jsx-equals-spacing", convertJsxEqualsSpacing], ["jsx-key", convertJsxKey], ["jsx-no-bind", convertJsxNoBind], + ["jsx-self-close", convertJsxSelfClose], ["jsx-wrap-multiline", convertJsxWrapMultiline], ["label-position", convertLabelPosition], ["linebreak-style", convertLinebreakStyle],