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

indent rule applied inside of multi-line template strings #1611

Closed
nonplus opened this issue Oct 9, 2016 · 1 comment
Closed

indent rule applied inside of multi-line template strings #1611

nonplus opened this issue Oct 9, 2016 · 1 comment

Comments

@nonplus
Copy link
Contributor

nonplus commented Oct 9, 2016

Bug Report

  • TSLint version: 3.15.1
  • TypeScript version: 2.0.3
  • Running TSLint via: CLI

TypeScript code being linted

// (second line in the template string has 3 leading spaces)
let sql = `SELECT *
   FROM user
   WHERE name = 'bob'`;

with tslint.json configuration:

{
    "rules": {
        "indent": [
            true,
            "tabs"
        ]
}

Actual behavior

TSLint logs an (indent) db/test.ts[1, 1]: tab indentation expected error.

Expected behavior

No error should be logged.

Workaround:

/* tslint:disable:indent */
let sql = `SELECT *
   FROM user
   WHERE name = 'bob'`;
/* tslint:enable:indent */

Notes:

Indentation should be ignored inside the literal portion of a template string (InTemplateHeadOrNoSubstitutionTemplate and InTemplateMiddleOrTail).

However, I think it makes sense to check for indentation within template substitution. So the following should be considered an indentation error:

let name = "Bob";
// (second line in the template string has 3 leading spaces)
let s = `Hello ${
   name
}, how are you?`;
@JoshuaKGoldberg
Copy link
Contributor

Looks like this was fixed! 🎉

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

2 participants