Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabs should be allowed in template literal strings #1096

Closed
DarrenCook opened this issue Mar 23, 2018 · 6 comments

Comments

@DarrenCook
Copy link

commented Mar 23, 2018

`   0	0048	H
   1	0065	e`

I'm getting "Unexpected tab character." complaints on the above string. I think specifying exact whitespace is one of the points of using template literals, so it should not be complaining?

Yeah, I've put:

/* eslint-disable no-tabs */

at the top of the file and moved on. But that seems like overkill - a template literal string is the only place I can think that I would want tab characters.

@Yamboy1

This comment has been minimized.

Copy link

commented Apr 25, 2018

Why are you using tabs specifically? Why not indent it using spaces?

@DarrenCook

This comment has been minimized.

Copy link
Author

commented Apr 25, 2018

Because I need tabs not spaces ;-)

In this case it was a unit test validating tab-separated output from a function. But, more generally, a lint checker should not be checking anything at all inside a template literal string (except the code inside the ${} sections, of course).

@LinusU

This comment has been minimized.

Copy link
Member

commented Apr 25, 2018

In this case it was a unit test validating tab-separated output from a function. But, more generally, a lint checker should not be checking anything at all inside a template literal string

I personally think that this is debatable.

I see your point and use case, and it's definitely valid. But I also think that it might be hard to spot that when glancing over the file, and personally would prefer explicitly writing \t in this case. It's similar to trailing whitespace, should that be allowed in template strings? I've actually broken a test in a project by simply saving a file with Atom, as it trimmed trailing spaces. It would probably have been better to be explicit in those cases and do ${' '} at the end of that line...

Just my 2¢

@Yamboy1

This comment has been minimized.

Copy link

commented Apr 26, 2018

That was my thought as well

@feross

This comment has been minimized.

Copy link
Member

commented Apr 30, 2018

@DarrenCook Does @LinusU's solution of using an explicit \t work for you? It sounds reasonable to me. But do share if there's something we're missing.

@no-response no-response bot closed this May 10, 2018

@no-response

This comment has been minimized.

Copy link

commented May 10, 2018

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please leave a comment or open a new issue if you have the additional information we need so investigate further.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.