Skip to content

Commit

Permalink
Turn on no-unused-variable rule
Browse files Browse the repository at this point in the history
- Fixes palantir#505
- Also rename some variables to better adhere to variable-name rule
  • Loading branch information
adidahiya committed Aug 13, 2015
1 parent d8a3402 commit 9e2cbcd
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 164 deletions.
2 changes: 1 addition & 1 deletion lib/tslint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ declare module Lint {
declare module Lint {
interface LintResult {
failureCount: number;
failures: RuleFailure[];
format: string;
output: string;
failures: RuleFailure[];
}
interface ILinterOptions {
configuration: any;
Expand Down
4 changes: 2 additions & 2 deletions src/formatterLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module Lint {
const fs = require("fs");
const path = require("path");
const _s = require("underscore.string");
const {camelize} = require("underscore.string");

const moduleDirectory = path.dirname(module.filename);
const CORE_FORMATTERS_DIRECTORY = path.resolve(moduleDirectory, "..", "build", "formatters");
Expand All @@ -27,7 +27,7 @@ module Lint {
return name;
}

const camelizedName = _s.camelize(name + "Formatter");
const camelizedName = camelize(name + "Formatter");

// first check for core formatters
let Formatter = loadFormatter(CORE_FORMATTERS_DIRECTORY, camelizedName);
Expand Down
8 changes: 4 additions & 4 deletions src/ruleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module Lint {
const fs = require("fs");
const path = require("path");
const _s = require("underscore.string");
const {camelize, strLeft, strRight} = require("underscore.string");

const moduleDirectory = path.dirname(module.filename);
const CORE_RULES_DIRECTORY = path.resolve(moduleDirectory, "..", "build", "rules");
Expand Down Expand Up @@ -68,8 +68,8 @@ module Lint {
// finally check for rules within the first level of directories,
// using dash prefixes as the sub-directory names
if (rulesDirectory) {
const subDirectory = _s.strLeft(rulesDirectory, "-");
const ruleName = _s.strRight(rulesDirectory, "-");
const subDirectory = strLeft(rulesDirectory, "-");
const ruleName = strRight(rulesDirectory, "-");
if (subDirectory !== rulesDirectory && ruleName !== rulesDirectory) {
camelizedName = transformName(ruleName);
Rule = loadRule(rulesDirectory, subDirectory, camelizedName);
Expand All @@ -89,7 +89,7 @@ module Lint {
if (nameMatch == null) {
return name + "Rule";
}
return nameMatch[1] + _s.camelize(nameMatch[2]) + nameMatch[3] + "Rule";
return nameMatch[1] + camelize(nameMatch[2]) + nameMatch[3] + "Rule";
}

function loadRule(...paths: string[]) {
Expand Down
6 changes: 2 additions & 4 deletions src/rules/labelPositionRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = "unexpected label on statement";

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new LabelPosWalker(sourceFile, this.getOptions()));
return this.applyWithWalker(new LabelPositionWalker(sourceFile, this.getOptions()));
}
}

class LabelPosWalker extends Lint.RuleWalker {
private isValidLabel: boolean;

class LabelPositionWalker extends Lint.RuleWalker {
public visitLabeledStatement(node: ts.LabeledStatement) {
const statement = node.statement;
if (statement.kind !== ts.SyntaxKind.DoStatement
Expand Down
1 change: 0 additions & 1 deletion src/rules/noShadowedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class NoShadowedVariableWalker extends Lint.BlockScopeAwareRuleWalker<ScopeInfo,
const variableIdentifier = <ts.Identifier> node.name;
const variableName = variableIdentifier.text;
const currentScope = this.getCurrentScope();
const currentBlockScope = this.getCurrentBlockScope();

if (this.isVarInAnyScope(variableName)) {
this.addFailureOnIdentifier(variableIdentifier);
Expand Down
1 change: 0 additions & 1 deletion src/rules/noSwitchCaseFallThroughRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class NoSwitchCaseFallThroughWalker extends Lint.RuleWalker {

private fallThroughAllowed(nextCaseOrDefaultStatement: ts.Node) {
const sourceFileText = nextCaseOrDefaultStatement.getSourceFile().text;
const childCount = nextCaseOrDefaultStatement.getChildCount();
const firstChild = nextCaseOrDefaultStatement.getChildAt(0);
const commentRanges = ts.getLeadingCommentRanges(sourceFileText, firstChild.getFullStart());
if (commentRanges != null) {
Expand Down
2 changes: 0 additions & 2 deletions src/rules/noVarKeywordRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

const OPTION_LEADING_UNDERSCORE = "no-var-keyword";

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = "forbidden var keyword";

Expand Down
Loading

0 comments on commit 9e2cbcd

Please sign in to comment.