Skip to content

Commit

Permalink
Merge pull request palantir#470 from palantir/comments
Browse files Browse the repository at this point in the history
turn on comment rule in TSLint and fix comments
  • Loading branch information
adidahiya committed Jun 26, 2015
2 parents 7e4806a + 4e7d5d3 commit 807fa3e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module Lint.Configuration {
return JSON.parse(fs.readFileSync(configFile, "utf8"));
}

// First look for package.json from input file location
// first look for package.json from input file location
configFile = findup("package.json", { cwd: inputFileLocation, nocase: true });

if (configFile) {
Expand All @@ -52,9 +52,8 @@ module Lint.Configuration {
}
}

// Next look for tslint.json
// next look for tslint.json
const homeDir = getHomeDir();

if (!homeDir) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/indentRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Rule extends Lint.Rules.AbstractRule {
}
}

// Visit every token and enforce that only the right character is used for indentation
// visit every token and enforce that only the right character is used for indentation
class IndentWalker extends Lint.RuleWalker {
private failureString: string;
private regExp: RegExp;
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noDuplicateVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NoDuplicateVariableWalker extends Lint.BlockScopeAwareRuleWalker<{}, Scope
}

public visitBindingElement(node: ts.BindingElement) {
// TODO: handle node.dotdotToken?
// #471: handle node.dotdotToken?
const isSingleVariable = node.name.kind === ts.SyntaxKind.Identifier;
const isBlockScoped = Lint.isBlockScopedBindingElement(node);

Expand Down
4 changes: 2 additions & 2 deletions src/rules/noShadowedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NoShadowedVariableWalker extends Lint.BlockScopeAwareRuleWalker<ScopeInfo,
}

public visitBindingElement(node: ts.BindingElement) {
// TODO: handle node.dotDotDotToken?
// #471: handle node.dotDotDotToken?
const isSingleVariable = node.name.kind === ts.SyntaxKind.Identifier;
const isBlockScoped = Lint.isBlockScopedBindingElement(node);

Expand All @@ -54,7 +54,7 @@ class NoShadowedVariableWalker extends Lint.BlockScopeAwareRuleWalker<ScopeInfo,
}

public visitParameterDeclaration(node: ts.ParameterDeclaration) {
// Treat parameters as block-scoped variables
// treat parameters as block-scoped variables
const variableIdentifier = <ts.Identifier> node.name;
const variableName = variableIdentifier.text;
const currentScope = this.getCurrentScope();
Expand Down
10 changes: 6 additions & 4 deletions src/rules/sortObjectLiteralKeysRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ export class Rule extends Lint.Rules.AbstractRule {
}

class SortedKeyWalker extends Lint.RuleWalker {
// Stacks are used to maintain state while recursing through nested object literals.
// stacks are used to maintain state while recursing through nested object literals
private lastSortedKeyStack: string[] = [];
private sortedStateStack: boolean[] = [];

public visitObjectLiteralExpression(node: ts.ObjectLiteralExpression) {
this.lastSortedKeyStack.push(""); // Char code 0; every string should be >= to this
this.sortedStateStack.push(true); // Sorted state is always initially true
// char code 0; every string should be >= to this
this.lastSortedKeyStack.push("");
// sorted state is always initially true
this.sortedStateStack.push(true);
super.visitObjectLiteralExpression(node);
this.lastSortedKeyStack.pop();
this.sortedStateStack.pop();
}

public visitPropertyAssignment(node: ts.PropertyAssignment) {
const sortedState = this.sortedStateStack[this.sortedStateStack.length - 1];
// Skip remainder of object literal scan if a previous key was found
// skip remainder of object literal scan if a previous key was found
// in an unsorted position. This ensures only one error is thrown at
// a time and keeps error output clean.
if (sortedState) {
Expand Down
2 changes: 1 addition & 1 deletion src/tslint-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ tslint accepts the following commandline options:
process.exit(0);
}

// When provided it should point to an existing location
// when provided, it should point to an existing location
if (argv.c && !fs.existsSync(argv.c)) {
console.error("Invalid option for configuration: " + argv.c);
process.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions test/rules/indentRuleTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("<indent>", () => {
Lint.Test.assertContainsFailure(actualFailures, failure);
}

// Checks only that the indent character is the specified one, *NOT* the size of the indent
// checks only that the indent character is the specified one, *NOT* the size of the indent
describe("on a tab-indented file", () => {
const fileName = "rules/indentwith_tabs.test.ts";

Expand Down Expand Up @@ -75,7 +75,7 @@ describe("<indent>", () => {
});
});

// Checks only that the indent character is the specified one, *NOT* the size of the indent
// checks only that the indent character is the specified one, *NOT* the size of the indent
describe("on a space-indented file", () => {
const fileName = "rules/indentwith_spaces.test.ts";

Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"rules": {
"class-name": true,
"comment-format": [true, "check-lowercase", "check-space"],
"curly": true,
"eofline": true,
"forin": true,
Expand Down

0 comments on commit 807fa3e

Please sign in to comment.