Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
[bug] fixed no-inner-declarations rule (refs #75)
Browse files Browse the repository at this point in the history
  • Loading branch information
buzinas committed Apr 7, 2016
1 parent c58c5d4 commit 49f410c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rules/noInnerDeclarationsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class NoInnerDeclarationsWalker extends Lint.RuleWalker {

private validateInnerDeclaration(node: ts.Node) {
const body = this.nearestBody(node);
const isValid = (body.kind === ts.SyntaxKind.SourceFile && body.distance === 1) || body.distance === 2;
const isValid = (body.isSourceFile && body.distance === 1) || body.distance === 2;

if (!isValid) {
const decl = node.kind === ts.SyntaxKind.FunctionDeclaration ? 'function' : 'variable';
const root = body.kind === ts.SyntaxKind.SourceFile ? 'program' : 'function body';
const root = body.isSourceFile ? 'program' : 'function body';

this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `move ${decl} declaration to ${root} root`));
}
Expand All @@ -52,7 +52,7 @@ class NoInnerDeclarationsWalker extends Lint.RuleWalker {
}

return {
kind: ancestor.kind,
isSourceFile: (ancestor && ancestor.kind === ts.SyntaxKind.SourceFile) || !ancestor,
distance: generation
};
}
Expand Down

0 comments on commit 49f410c

Please sign in to comment.