-
-
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.
rxjs-no-wholesale makes more sense, as it can be use in combination with rxjs-no-add and rxjs-no-patched.
- Loading branch information
Showing
7 changed files
with
55 additions
and
36 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
File renamed without changes.
File renamed without changes.
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
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,42 @@ | ||
/** | ||
* @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 ts from "typescript"; | ||
|
||
export class Rule extends Lint.Rules.AbstractRule { | ||
|
||
public static metadata: Lint.IRuleMetadata = { | ||
description: "Disallows the wholesale importation of `rxjs` or `rxjs/Rx`.", | ||
options: null, | ||
optionsDescription: "Not configurable.", | ||
requiresTypeInfo: false, | ||
ruleName: "rxjs-no-wholesale", | ||
type: "style", | ||
typescriptOnly: false | ||
}; | ||
|
||
public static FAILURE_STRING = "Wholesale RxJS imports are forbidden"; | ||
|
||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { | ||
return this.applyWithWalker(new Walker(sourceFile, this.getOptions())); | ||
} | ||
} | ||
|
||
class Walker extends Lint.RuleWalker { | ||
|
||
public visitImportDeclaration(node: ts.ImportDeclaration): void { | ||
|
||
const moduleSpecifier = node.moduleSpecifier.getText(); | ||
|
||
if (/^['"]rxjs(\/Rx)?['"]/.test(moduleSpecifier)) { | ||
this.addFailureAtNode(node, Rule.FAILURE_STRING); | ||
} | ||
|
||
super.visitImportDeclaration(node); | ||
} | ||
} |
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