Skip to content

Commit

Permalink
feat: change no-compat rule for forbid imports from rxjs/operators
Browse files Browse the repository at this point in the history
  • Loading branch information
pumano committed Aug 11, 2023
1 parent c09676b commit 708a1e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/rules/no-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const rule = ruleCreator({
name: "no-compat",
create: (context) => {
return {
[String.raw`ImportDeclaration Literal[value=/^rxjs\u002f/]:not(Literal[value=/^rxjs\u002f(ajax|fetch|operators|testing|webSocket)/])`]:
[String.raw`ImportDeclaration Literal[value=/^rxjs\u002f/]:not(Literal[value=/^rxjs\u002f(ajax|fetch|testing|webSocket)/])`]:
(node: es.Literal) => {
context.report({
messageId: "forbidden",
Expand Down
7 changes: 6 additions & 1 deletion tests/rules/no-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ruleTester({ types: false }).run("no-compat", rule, {
`import { Observable } from "rxjs";`,
`import { ajax } from "rxjs/ajax";`,
`import { fromFetch } from "rxjs/fetch";`,
`import { concatMap } from "rxjs/operators";`,
`import { TestScheduler } from "rxjs/testing";`,
`import { webSocket } from "rxjs/webSocket";`,
`import * as prefixedPackage from "rxjs-prefixed-package";`,
Expand Down Expand Up @@ -49,6 +48,12 @@ ruleTester({ types: false }).run("no-compat", rule, {
~~~~~~~~~~~~~~~~~~~~~ [forbidden]
`
),
fromFixture(
stripIndent`
import { merge } from "rxjs/operators";
~~~~~~~~~~~~~~~~ [forbidden]
`
),
fromFixture(
stripIndent`
import { asap } from "rxjs/scheduler/asap";
Expand Down

0 comments on commit 708a1e4

Please sign in to comment.