From 3d8d9fe4ae46df8fb62960223859319eb26346cf Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 12 Dec 2020 15:09:02 -0500 Subject: [PATCH 1/2] Added converter for jsx-no-lambda --- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../eslint-plugin-react/jsx-no-lambda.ts | 13 +++++++++++++ .../tests/jsx-no-lambda.test.ts | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-no-lambda.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 4baf906e4..f3cdd0067 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 { convertJsxNoLambda } from "./ruleConverters/eslint-plugin-react/jsx-no-lambda"; 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-no-lambda", convertJsxNoLambda], ["jsx-wrap-multiline", convertJsxWrapMultiline], ["label-position", convertLabelPosition], ["linebreak-style", convertLinebreakStyle], diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-no-lambda.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-no-lambda.ts new file mode 100644 index 000000000..62f52b363 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/jsx-no-lambda.ts @@ -0,0 +1,13 @@ +import { RuleConverter } from "../../ruleConverter"; + +export const convertJsxNoLambda: RuleConverter = () => { + return { + rules: [ + { + notices: ["ESLint rule 'jsx-no-bind' also checks for Function.bind"], + ruleName: "react/jsx-no-bind", + }, + ], + plugins: ["eslint-plugin-react"], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts new file mode 100644 index 000000000..9904f2229 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts @@ -0,0 +1,19 @@ +import { convertJsxNoLambda } from "../jsx-no-lambda"; + +describe(convertJsxNoLambda, () => { + test("conversion without arguments", () => { + const result = convertJsxNoLambda({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + notices: ["ESLint rule 'jsx-no-bind' also checks for Function.bind"], + ruleName: "react/jsx-key", + }, + ], + plugins: ["eslint-plugin-react"], + }); + }); +}); From cdd709937512ddec5e80b41bcaf28f16fdcc3394 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 12 Dec 2020 15:19:19 -0500 Subject: [PATCH 2/2] Test... --- .../eslint-plugin-react/tests/jsx-no-lambda.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts index 9904f2229..d57750c2a 100644 --- a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-react/tests/jsx-no-lambda.test.ts @@ -10,7 +10,7 @@ describe(convertJsxNoLambda, () => { rules: [ { notices: ["ESLint rule 'jsx-no-bind' also checks for Function.bind"], - ruleName: "react/jsx-key", + ruleName: "react/jsx-no-bind", }, ], plugins: ["eslint-plugin-react"],