Skip to content

Commit

Permalink
[new-fixer]: Add space before comment message fixer (palantir#3845)
Browse files Browse the repository at this point in the history
* [new-fixer]: Add space before comment message fixer

* Add space-before-comment test
  • Loading branch information
tanniiz authored and suchanlee committed Apr 26, 2018
1 parent f399c3c commit 6bc44a2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rules/commentFormatRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class Rule extends Lint.Rules.AbstractRule {
],
type: "style",
typescriptOnly: false,
hasFix: true,
};
/* tslint:enable:object-literal-sort-keys */

Expand Down Expand Up @@ -179,7 +180,7 @@ function walk(ctx: Lint.WalkContext<Options>) {
}

if (ctx.options.space && commentText[0] !== " ") {
ctx.addFailure(start, end, Rule.LEADING_SPACE_FAILURE);
ctx.addFailure(start, end, Rule.LEADING_SPACE_FAILURE, [ Lint.Replacement.appendText(start, " ") ]);
}

if (ctx.options.case === Case.None ||
Expand Down
30 changes: 30 additions & 0 deletions test/rules/comment-format/exceptions-pattern/test.ts.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
///<reference path="something.ts"/>
class Clazz { // this comment is correct
/* block comment
* adada
*/
public funcxion() { // This comment has a capital letter starting it
// This comment is on its own line, and starts with a capital _and_ no space
console.log("test"); // this comment has no space
}
/// <not a reference/>
//// foo
}

//#region test
//#endregion

`${location.protocol}//${location.hostname}`

//noinspection JSUnusedGlobalSymbols
const unusedVar = 'unneeded value';

// TODO: Write more tests
// HACKING is not an exception

// STDIN for input
// STDOUT for output
// stderr for errors



0 comments on commit 6bc44a2

Please sign in to comment.