Skip to content

Commit

Permalink
fix: Match adjacent siblings only.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Nov 18, 2019
1 parent 92dc168 commit f356b7b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/rules/rxjsNoRedundantNotifyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Rule extends Lint.Rules.TypedRule {
): Lint.RuleFailure[] {
const failures: Lint.RuleFailure[] = [];
const typeChecker = program.getTypeChecker();
const query = `ExpressionStatement[expression.expression.name.text=/^(complete|error)$/] ~ ExpressionStatement[expression.expression.name.text=/^(next|complete|error)$/]`;
const query = `ExpressionStatement[expression.expression.name.text=/^(complete|error)$/] + ExpressionStatement[expression.expression.name.text=/^(next|complete|error)$/]`;
const expressionStatements = tsquery(sourceFile, query);
expressionStatements.forEach((node: ts.ExpressionStatement) => {
const { parent } = node;
Expand All @@ -38,15 +38,15 @@ export class Rule extends Lint.Rules.TypedRule {
const { statements } = parent;
const index = statements.indexOf(node);
const sibling = statements[index - 1] as ts.ExpressionStatement;
if (getExpressionText(sibling) !== getExpressionText(node)) {
return;
}
if (
!isExpressionObserver(sibling, typeChecker) ||
!isExpressionObserver(node, typeChecker)
) {
return;
}
if (getExpressionText(sibling) !== getExpressionText(node)) {
return;
}
const expressionStatement = node;
if (ts.isCallExpression(expressionStatement.expression)) {
const callExpression = expressionStatement.expression;
Expand Down

0 comments on commit f356b7b

Please sign in to comment.