eslint-plugin-rxjs-angular
Version:
ESLint rules for RxJS and Angular
56 lines (43 loc) • 2.81 kB
Markdown
# eslint-plugin-rxjs-angular
[](https://github.com/cartant/eslint-plugin-rxjs-angular/blob/master/LICENSE)
[](https://www.npmjs.com/package/eslint-plugin-rxjs-angular)
[](https://npmjs.org/package/eslint-plugin-rxjs-angular)
[](https://app.circleci.com/pipelines/github/cartant)
[](https://david-dm.org/cartant/eslint-plugin-rxjs-angular)
[](https://david-dm.org/cartant/eslint-plugin-rxjs-angular#info=devDependencies)
[](https://david-dm.org/cartant/eslint-plugin-rxjs-angular#info=peerDependencies)
This package contains ESLint versions of the Angular/RxJS rules that are in the [`rxjs-tslint-rules`](https://github.com/cartant/rxjs-tslint-rules) package.
There is no recommended configuration for this package, as all of the rules are opinionated.
# Install
Install the ESLint TypeScript parser using npm:
```
npm install @typescript-eslint/parser --save-dev
```
Install the package using npm:
```
npm install eslint-plugin-rxjs-angular --save-dev
```
Configure the `parser` and the `parserOptions` for ESLint. Here, I use a `.eslintrc.js` file for the configuration:
```js
const { join } = require("path");
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2019,
project: join(__dirname, "./tsconfig.json"),
sourceType: "module"
},
plugins: ["rxjs-angular"],
extends: [],
rules: {
"rxjs-angular/prefer-async-pipe": "error"
}
};
```
# Rules
The package includes the following rules:
| Rule | Description | Recommended |
| --- | --- | --- |
| [`prefer-async-pipe`](https://github.com/cartant/eslint-plugin-rxjs-angular/blob/main/docs/rules/prefer-async-pipe.md) | Forbids the calling of `subscribe` within Angular components. | No |
| [`prefer-composition`](https://github.com/cartant/eslint-plugin-rxjs-angular/blob/main/docs/rules/prefer-composition.md) | Forbids `subscribe` calls that are not composed within Angular components (and, optionally, within services, directives, and pipes). | No |
| [`prefer-takeuntil`](https://github.com/cartant/eslint-plugin-rxjs-angular/blob/main/docs/rules/prefer-takeuntil.md) | Forbids Calling `subscribe` without an accompanying `takeUntil`. | No |