Disallow importing operators from rxjs/operators (rxjs-x/prefer-root-operators)
April 18, 2025 ยท View on GitHub
๐ผ This rule is enabled in the following configs: โ
recommended, ๐ strict.
๐ง๐ก This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.
This rule prevents importing from the rxjs/operators export site.
Most operators were moved to the rxjs export site in RxJS v7.2.0
(excepting a few old and deprecated operators).
The rxjs/operators export site has since been deprecated and will be removed in a future major version.
Note that because a few operators were renamed or not migrated to the rxjs export site,
this rule may not provide an automatic fixer if renaming the import path is not guaranteed to be safe.
See the documentation linked below.
Rule details
Examples of incorrect code for this rule:
import { map } from 'rxjs/operators';
Examples of correct code for this rule:
import { map } from 'rxjs';
When Not To Use It
If you don't care about importing from the deprecated site, then you don't need this rule.
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.