Fixes #163 trailing whitespace rule doesn't always work

* the flaw was that the rule didn't take into account leading whitespace
* there was also a bug where it didn't handle multiple lines of trailing
whitespace in a row
Ah yeah, I was having some trouble with position and forgot to clean that up - it's probably not necessary for it to be so verbose. Wanna just take my change and update that or I can change it when I get in. Up to you - I just wanna get the rule fixed ASAP :)

Derek
Sent from a tablet

On Jun 27, 2014, at 11:11 AM, "ashwinr" <notifications@github.com<mailto:notifications@github.com>> wrote:


In src/rules/noTrailingWhitespaceRule.ts:

> @@ -25,29 +25,36 @@ export class Rule extends Lint.Rules.AbstractRule {
>  }
>
>  class NoTrailingWhitespaceWalker extends Lint.RuleWalker {
> -    public visitToken(token: TypeScript.ISyntaxToken): void {
> +
> +    public visitToken(token: TypeScript.ISyntaxToken) {
> +        var leadingTrivia = token.leadingTrivia();
> +        var trailingTrivia = token.trailingTrivia();
> +        var position = this.position();
> +        var trailingPosition = position + (token.fullWidth() - leadingTrivia.fullWidth() - trailingTrivia.fullWidth());


hmm, maybe actually: position + leadingTrivia.fullWidth() + token.width()

—
Reply to this email directly or view it on GitHub<https://urldefense.proofpoint.com/v1/url?u=https://github.com/palantir/tslint/pull/174/files%23r14297395&k=fDZpZZQMmYwf27OU23GmAQ%3D%3D%0A&r=G9IxOYYa23sRJ3oFAAoPyM4S839dobW6vZTEcOJ3HLw%3D%0A&m=w59Q2j7D9Yg5aDmpNd%2FGKpr3Iwdi18xLkLjcjqmvqMc%3D%0A&s=a12507b7f1388f4e6931d9c7ab6a08e9ba40eefca2b8ac9b64ff85110359072b>.