-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "rxjs/add/operator/map"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Observable } from "rxjs/Observable"; | ||
import { Subject } from "rxjs/Subject"; | ||
import { filter } from "rxjs/operator/filter"; | ||
|
||
const subject = new Subject<number>(); | ||
const filtered = filter.call(subject, (value) => value > 1) as Observable<number>; | ||
const mapped = filtered.map((value) => value + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"lib": ["es2015"], | ||
"noEmit": true, | ||
"paths": { | ||
"rxjs": ["../node_modules/rxjs"] | ||
}, | ||
"skipLibCheck": true, | ||
"target": "es5" | ||
}, | ||
"include": ["adds.ts", "fixture.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"defaultSeverity": "error", | ||
"jsRules": {}, | ||
"rules": { | ||
"rxjs-no-patched": { "severity": "error" } | ||
}, | ||
"rulesDirectory": "../../build/rules" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license Copyright © 2017 Nicholas Jamieson. All Rights Reserved. | ||
* 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/rxjs-tslint-rules | ||
*/ | ||
/*tslint:disable:no-use-before-declare*/ | ||
|
||
import * as Lint from "tslint"; | ||
import * as path from "path"; | ||
import * as ts from "typescript"; | ||
|
||
import { UsedWalker } from "../support/used-walker"; | ||
|
||
export class Rule extends Lint.Rules.TypedRule { | ||
|
||
public static metadata: Lint.IRuleMetadata = { | ||
description: "Disallows the calling of patched methods.", | ||
options: null, | ||
optionsDescription: "Not configurable.", | ||
requiresTypeInfo: true, | ||
ruleName: "rxjs-no-patched", | ||
type: "functionality", | ||
typescriptOnly: true | ||
}; | ||
|
||
public static FAILURE_STRING = "RxJS patched methods are forbidden"; | ||
|
||
public applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] { | ||
|
||
return this.applyWithWalker(new Walker(sourceFile, this.getOptions(), program)); | ||
} | ||
} | ||
|
||
class Walker extends UsedWalker { | ||
|
||
protected onSourceFileEnd(): void { | ||
|
||
Object.keys(this.usedObservables).forEach((key) => { | ||
|
||
this.usedObservables[key].forEach((node) => this.addFailureAtNode( | ||
node, | ||
`${Rule.FAILURE_STRING}: ${key}` | ||
)); | ||
}); | ||
|
||
Object.keys(this.usedOperators).forEach((key) => { | ||
|
||
this.usedOperators[key].forEach((node) => this.addFailureAtNode( | ||
node, | ||
`${Rule.FAILURE_STRING}: ${key}` | ||
)); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters