Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Consecutive blank lines are forbidden should not apply inside template strings #1886

Closed
corbinu opened this issue Dec 16, 2016 · 4 comments
Closed

Comments

@corbinu
Copy link

corbinu commented Dec 16, 2016

Bug Report

  • TSLint version: 4.0.0
  • TypeScript version: 2.1.4
  • Running TSLint via: npm script

TypeScript code being linted

const str = `
    here is some text


`;

with tslint.json configuration:

"rules": {
    "no-consecutive-blank-lines": [
        true
    ]
}

Actual behavior

Treats the consecutive blank lines inside the string as a violation

Expected behavior

Don't treat the consecutive blank lines inside the string as a violation

@adidahiya
Copy link
Contributor

sounds like a bug, accepting PRs

@IllusionMH
Copy link
Contributor

Is there any alternatives to getTokenAtPosition function?
There is easy fix with

const token = (ts as any).getTokenAtPosition(node, start) as ts.Node;

but it is not a part of public API (however ts as any already used in noInferredEmptyObjectTypeRule.ts#L55 )

I tried to use LanguageService but none of methods that has AtPosition returns needed info.

@nchen63
Copy link
Contributor

nchen63 commented Dec 17, 2016

the ts as any was only used there to handle backcompat with TypeScript v2.0, since the field doesn't exist in Typescript v2.1.

Seems strange that getTokenAtPosition is not public. I don't think we should be using private functions. I guess the alternative would be to walk every node to find the template string nodes, then filter the errors

@ajafff
Copy link
Contributor

ajafff commented Dec 22, 2016

I have a fix in my local fork. Will prepare a PR tomorrow(ish)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants