From 2fba6c29758657d1f3f7bd4bf24649cddf64d240 Mon Sep 17 00:00:00 2001 From: Krzysztof Brilla Date: Sat, 31 Oct 2020 14:19:09 +0100 Subject: [PATCH 1/3] Adding the rule, mapping it and writing the tests --- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../eslint-plugin-rxjs/no-async-subscribe.ts | 12 ++++++++++++ .../tests/no-async-subscribe.test.ts | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-async-subscribe.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-async-subscribe.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 37010c5cd..03ee094cd 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -180,6 +180,7 @@ import { convertJsxEqualsSpacing } from "./ruleConverters/eslint-plugin-react/js import { convertJsxKey } from "./ruleConverters/eslint-plugin-react/jsx-key"; import { convertJsxNoBind } from "./ruleConverters/eslint-plugin-react/jsx-no-bind"; import { convertJsxWrapMultiline } from "./ruleConverters/eslint-plugin-react/jsx-wrap-multiline"; +import { convertNoAsyncSubscribe } from "./ruleConverters/eslint-plugin-rxjs/no-async-subscribe"; /** * Keys TSLint rule names to their ESLint rule converters. @@ -364,6 +365,7 @@ export const ruleConverters = new Map([ ["use-pipe-decorator", convertUsePipeDecorator], ["use-pipe-transform-interface", convertUsePipeTransformInterface], ["variable-name", convertVariableName], + ["rxjs/no-async-subscribe", convertNoAsyncSubscribe], // 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-async-subscribe.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-async-subscribe.ts new file mode 100644 index 000000000..8252efe57 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-async-subscribe.ts @@ -0,0 +1,12 @@ +import { RuleConverter } from "../../ruleConverter"; + +export const convertNoAsyncSubscribe: RuleConverter = () => { + return { + rules: [ + { + ruleName: "no-async-subscribe", + }, + ], + plugins: ["eslint-plugin-rxjs"], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-async-subscribe.test.ts b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-async-subscribe.test.ts new file mode 100644 index 000000000..40cdeedf1 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-async-subscribe.test.ts @@ -0,0 +1,18 @@ +import { convertNoAsyncSubscribe } from "../no-async-subscribe"; + +describe(convertNoAsyncSubscribe, () => { + test("conversion without arguments", () => { + const result = convertNoAsyncSubscribe({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "no-async-subscribe", + }, + ], + plugins: ["eslint-plugin-rxjs"], + }); + }); +}); From 9160ec0f057c58ced896965cf0abf99cb33650b2 Mon Sep 17 00:00:00 2001 From: Krzysztof Brilla Date: Sat, 31 Oct 2020 14:28:50 +0100 Subject: [PATCH 2/3] added import comment --- 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 03ee094cd..b785ad50b 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -180,6 +180,8 @@ import { convertJsxEqualsSpacing } from "./ruleConverters/eslint-plugin-react/js import { convertJsxKey } from "./ruleConverters/eslint-plugin-react/jsx-key"; import { convertJsxNoBind } from "./ruleConverters/eslint-plugin-react/jsx-no-bind"; import { convertJsxWrapMultiline } from "./ruleConverters/eslint-plugin-react/jsx-wrap-multiline"; + +//eslint-plugin-rxjs converters import { convertNoAsyncSubscribe } from "./ruleConverters/eslint-plugin-rxjs/no-async-subscribe"; /** From bf9ba4df93717088351a719689863b252e6f88dc Mon Sep 17 00:00:00 2001 From: Krzysztof Brilla Date: Sat, 31 Oct 2020 14:48:45 +0100 Subject: [PATCH 3/3] typo in rule name --- src/converters/lintConfigs/rules/ruleConverters.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index b785ad50b..40c1f9c32 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -367,7 +367,7 @@ export const ruleConverters = new Map([ ["use-pipe-decorator", convertUsePipeDecorator], ["use-pipe-transform-interface", convertUsePipeTransformInterface], ["variable-name", convertVariableName], - ["rxjs/no-async-subscribe", convertNoAsyncSubscribe], + ["rxjs-no-async-subscribe", convertNoAsyncSubscribe], // 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...