From 39b6c86c6ce316a1d78b5d9c9b2c31be647ea26a Mon Sep 17 00:00:00 2001 From: Krzysztof Brilla Date: Sat, 7 Nov 2020 19:57:45 +0100 Subject: [PATCH] Adding the rule, mapping it and writing the tests --- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../eslint-plugin-rxjs/no-create.ts | 12 ++++++++++++ .../eslint-plugin-rxjs/tests/no-create.test.ts | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-create.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-create.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 40c1f9c32..2ae30da8e 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -183,6 +183,7 @@ import { convertJsxWrapMultiline } from "./ruleConverters/eslint-plugin-react/js //eslint-plugin-rxjs converters import { convertNoAsyncSubscribe } from "./ruleConverters/eslint-plugin-rxjs/no-async-subscribe"; +import { convertNoCreate } from "./ruleConverters/eslint-plugin-rxjs/no-create"; /** * Keys TSLint rule names to their ESLint rule converters. @@ -368,6 +369,7 @@ export const ruleConverters = new Map([ ["use-pipe-transform-interface", convertUsePipeTransformInterface], ["variable-name", convertVariableName], ["rxjs-no-async-subscribe", convertNoAsyncSubscribe], + ["rxjs-no-create", convertNoCreate], // These converters are all for rules that need more complex option conversions. // Some of them will likely need to have notices about changed lint behaviors... diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-create.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-create.ts new file mode 100644 index 000000000..5001c7594 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-create.ts @@ -0,0 +1,12 @@ +import { RuleConverter } from "../../ruleConverter"; + +export const convertNoCreate: RuleConverter = () => { + return { + rules: [ + { + ruleName: "rxjs/no-create", + }, + ], + plugins: ["eslint-plugin-rxjs"], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-create.test.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-create.test.ts new file mode 100644 index 000000000..a2e8661bc --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-create.test.ts @@ -0,0 +1,18 @@ +import { convertNoCreate } from "../no-create"; + +describe(convertNoCreate, () => { + test("conversion without arguments", () => { + const result = convertNoCreate({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "rxjs/no-create", + }, + ], + plugins: ["eslint-plugin-rxjs"], + }); + }); +});