Skip to content

Conversation

@birenrao
Copy link

In this PR I would like to add new rule: no-nested-pipe

Last year, my team have spent significant effort on improving the maintainability and readability of rxjs statement in the codebase. Avoiding nested pipe has been the most useful rule on driving the better behavior in this area. The team have been enforcing this manually through PR review check last year. I have come cross your library and find it very useful, hence would like to introduce no-nested-pipe rule so that we could all benefit from it.

would you please review this PR and suggest if there is any correction and could please approve this PR if everything is ok

this is just new rule created based on the no-nested-subscribe, in our code we found this one of big issue when its making code complex and have certain issue as well so we wanted to avoid nested pipe in the code currently there is not other solution available in the next
example in the docs about the growing code face issues with nested pipes for which we require this rule to avoid this complexity
added new test file for no-nested-pipe valid and invalid scenarios
rule usage standalone code for playground
test description update
Copy link
Owner

@JasonWeinzierl JasonWeinzierl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've left some comments. Additionally:

  • Run yarn lint and yarn typecheck and fix any problems.
  • Run yarn docs to auto-update the documentation instead of manually updating it.
  • You may need to re-create your branch off this repository instead of cartant's, since we've upgraded things like dependencies and the testing framework.

/**
* @license Use of this source code is governed by an MIT-style license that
* can be found in the LICENSE file at https://github.com/cartant/eslint-plugin-rxjs
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This license header can be removed (and in the test file too).


import { TSESTree as es } from "@typescript-eslint/experimental-utils";
import { getParent, getTypeServices } from "eslint-etc";
import { ruleCreator } from "../utils";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we've upgraded typescript-eslint and dropped the dependency on eslint-etc, you'll need slightly separate imports:

import { TSESTree as es } from '@typescript-eslint/utils';
import { getTypeServices } from '../etc';

...

And instead of getParent, you can just do node.parent.

},
});

export = rule;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're exporting rules slightly different to support ESM too. Do:

export const noNestedPipeRule = ruleCreator({
...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add the rule to index.ts (we have a unit test to ensure it gets added).

@birenrao birenrao closed this Jan 29, 2025
@birenrao birenrao deleted the no-nested-pipe branch January 29, 2025 09:59
@birenrao birenrao restored the no-nested-pipe branch January 29, 2025 09:59
@birenrao birenrao deleted the no-nested-pipe branch January 29, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants