Skip to content

Commit 2c762c4

Browse files
kbrillaKrzysztof BrillaJoshuaKGoldberg
authored
rxjs-no-unsafe-takeuntil and fix in rxjs-no-async-subscribe (#798)
* added .idea to gitignore * fix ruleName * fix test for no-async-subscribe * Adding the rule, mapping it and writing the tests * Revert "added .idea to gitignore" This reverts commit 3639616 Co-authored-by: Krzysztof Brilla <brilla.krzysztof@gmail.com> Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
1 parent 040fc68 commit 2c762c4

File tree

5 files changed

+69
-2
lines changed

5 files changed

+69
-2
lines changed

src/converters/lintConfigs/rules/ruleConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ import { convertNoSubjectUnubscribe } from "./ruleConverters/eslint-plugin-rxjs/
199199
import { convertNoSubjectValue } from "./ruleConverters/eslint-plugin-rxjs/no-subject-value";
200200
import { convertNoUnboundMethods } from "./ruleConverters/eslint-plugin-rxjs/no-unbound-methods";
201201
import { convertNoUnsafeSubjectNext } from "./ruleConverters/eslint-plugin-rxjs/no-unsafe-subject-next";
202+
import { convertNoUnsafeTakeUntil } from "./ruleConverters/eslint-plugin-rxjs/no-unsafe-takeuntil";
202203

203204
/**
204205
* Keys TSLint rule names to their ESLint rule converters.
@@ -400,6 +401,7 @@ export const ruleConverters = new Map([
400401
["rxjs-no-subject-value", convertNoSubjectValue],
401402
["rxjs-no-unbound-methods", convertNoUnboundMethods],
402403
["rxjs-no-unsafe-subject-next", convertNoUnsafeSubjectNext],
404+
["rxjs-no-unsafe-takeuntil", convertNoUnsafeTakeUntil],
403405

404406
// These converters are all for rules that need more complex option conversions.
405407
// Some of them will likely need to have notices about changed lint behaviors...

src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/no-async-subscribe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const convertNoAsyncSubscribe: RuleConverter = () => {
44
return {
55
rules: [
66
{
7-
ruleName: "no-async-subscribe",
7+
ruleName: "rxjs/no-async-subscribe",
88
},
99
],
1010
plugins: ["eslint-plugin-rxjs"],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RuleConverter } from "../../ruleConverter";
2+
3+
export const convertNoUnsafeTakeUntil: RuleConverter = (tslintRule) => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: tslintRule.ruleArguments,
9+
}),
10+
ruleName: "rxjs/no-unsafe-takeuntil",
11+
},
12+
],
13+
plugins: ["eslint-plugin-rxjs"],
14+
};
15+
};

src/converters/lintConfigs/rules/ruleConverters/eslint-plugin-rxjs/tests/no-async-subscribe.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe(convertNoAsyncSubscribe, () => {
99
expect(result).toEqual({
1010
rules: [
1111
{
12-
ruleName: "no-async-subscribe",
12+
ruleName: "rxjs/no-async-subscribe",
1313
},
1414
],
1515
plugins: ["eslint-plugin-rxjs"],
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { convertNoUnsafeTakeUntil } from "../no-unsafe-takeuntil";
2+
3+
describe(convertNoUnsafeTakeUntil, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoUnsafeTakeUntil({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "rxjs/no-unsafe-takeuntil",
13+
},
14+
],
15+
plugins: ["eslint-plugin-rxjs"],
16+
});
17+
});
18+
19+
test("conversion with alias argument", () => {
20+
const result = convertNoUnsafeTakeUntil({
21+
ruleArguments: [{ alias: ["untilDestroyed"] }],
22+
});
23+
24+
expect(result).toEqual({
25+
rules: [
26+
{
27+
ruleName: "rxjs/no-unsafe-takeuntil",
28+
ruleArguments: [{ alias: ["untilDestroyed"] }],
29+
},
30+
],
31+
plugins: ["eslint-plugin-rxjs"],
32+
});
33+
});
34+
35+
test("conversion with allow argument", () => {
36+
const result = convertNoUnsafeTakeUntil({
37+
ruleArguments: [{ allow: ["shareReplay", "share"] }],
38+
});
39+
40+
expect(result).toEqual({
41+
rules: [
42+
{
43+
ruleName: "rxjs/no-unsafe-takeuntil",
44+
ruleArguments: [{ allow: ["shareReplay", "share"] }],
45+
},
46+
],
47+
plugins: ["eslint-plugin-rxjs"],
48+
});
49+
});
50+
});

0 commit comments

Comments
 (0)