Skip to content

Commit 489a72e

Browse files
committed
fix: Don't ban root-imported operators.
1 parent fe22ae2 commit 489a72e

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

source/rules/ban-operators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const rule = ruleCreator({
6464
}
6565

6666
return {
67-
[String.raw`ImportDeclaration[source.value=/^rxjs(\u002foperators)?$/] > ImportSpecifier`]:
67+
[String.raw`ImportDeclaration[source.value=/^rxjs\u002foperators$/] > ImportSpecifier`]:
6868
(node: es.ImportSpecifier) => {
6969
const identifier = node.imported;
7070
const failure = getFailure(identifier.name);

tests/rules/ban-operators.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ ruleTester({ types: false }).run("ban-operators", rule, {
1616
{
1717
code: `import { concat, merge as m, mergeMap as mm } from "rxjs";`,
1818
},
19+
{
20+
// This won't effect errors, because only imports from "rxjs/operators"
21+
// are checked. To support banning operators from "rxjs", it'll need to
22+
// check types.
23+
code: `import { concat, merge as m, mergeMap as mm } from "rxjs";`,
24+
options: [
25+
{
26+
concat: true,
27+
merge: "because I say so",
28+
mergeMap: false,
29+
},
30+
],
31+
},
1932
],
2033
invalid: [
2134
fromFixture(
@@ -34,21 +47,5 @@ ruleTester({ types: false }).run("ban-operators", rule, {
3447
],
3548
}
3649
),
37-
fromFixture(
38-
stripIndent`
39-
import { concat, merge as m, mergeMap as mm } from "rxjs";
40-
~~~~~~ [forbidden { "name": "concat", "explanation": "" }]
41-
~~~~~ [forbidden { "name": "merge", "explanation": ": because I say so" }]
42-
`,
43-
{
44-
options: [
45-
{
46-
concat: true,
47-
merge: "because I say so",
48-
mergeMap: false,
49-
},
50-
],
51-
}
52-
),
5350
],
5451
});

0 commit comments

Comments
 (0)