ESLint rules for RxJS and Angular
npm install @rxlint/eslint-plugin-angular



This package is a fork of the package cartant/eslint-plugin-rxjs-angular with trimmed and updated dependencies to work with both eslint 8 and 9.
There is no recommended configuration for this package, as all of the rules are opinionated.
Install the ESLint TypeScript parser using npm:
``sh`
npm install --save-dev eslint typescript @typescript-eslint/parser @rxlint/eslint-plugin-angular --save-devor
yarn add --dev eslint typescript @typescript-eslint/parser @rxlint/eslint-plugin-angular
This plugin should work with both ESLint v8 eslintrc and ESLint v9 eslint.config.js format files.
For ESLint v8, add @rxlint/angular to your plugin array:
.eslintrc.js
`js`
module.exports = {
files: ["*/.ts"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
project: true,
sourceType: "module"
},
plugins: ["@rxlint/angular"],
rules: {
"@rxlint/angular/prefer-async-pipe": "error"
}
};
For ESLint v9, import the plugin and map it to a name:
eslint.config.js
`js
const rxjsAngular = require("@rxlint/eslint-plugin-angular");
module.exports = [{
files: ["*/.ts"],
plugins: {
"@rxlint-angular": rxjsAngular
},
rules: {
"@rxlint-angular/prefer-async-pipe": "error"
}
}];
`
The package includes the following rules:
| Rule | Description | Recommended |
| --- | --- | --- |
| prefer-async-pipe | Forbids the calling of subscribe within Angular components. | No |prefer-composition
| | Forbids subscribe calls that are not composed within Angular components (and, optionally, within services, directives, and pipes). | No |prefer-takeuntil
| | Forbids Calling subscribe without an accompanying takeUntil`. | No |