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

[Rule request] Single spaces #3787

Closed
rhys-vdw opened this issue Mar 21, 2018 · 6 comments
Closed

[Rule request] Single spaces #3787

rhys-vdw opened this issue Mar 21, 2018 · 6 comments

Comments

@rhys-vdw
Copy link

rhys-vdw commented Mar 21, 2018

I would like a rule to enforce the following:

// BAD!
const x     = 5
const y = x === 5     ? "foo" : "bar"

// good!
const x = 5
const y = x === 5 ? "foo" : "bar"

It seems whitespace will add a minimum spacing for many operators, but not limit a maximum number of spaces.

@ggarek
Copy link
Contributor

ggarek commented Mar 22, 2018

i guess, we are speaking about the rule as eslint/no-multi-spaces

@rhys-vdw check this package tslint-eslint-rules, it seems one can have the best from both worlds.

@timocov
Copy link
Contributor

timocov commented Jun 7, 2018

Also tslint (and seems that eslint too) allows using tabs as separator:

const abc	=	123; // actually here are tabs instead of spaces around `=`

I guess it will be useful to enforce to use spaces (or tabs? 🙂).

@ggarek
Copy link
Contributor

ggarek commented Jun 15, 2018

imo, it is better be an option, rather than a restriction. Because using tabs is completely valid and common, as well as using spaces.

@ceirbus
Copy link

ceirbus commented Sep 20, 2018

This would be so nice, my company is looking for a way to block multiple spaces before and after the equals operator (like this: ' = ') for variable declarations. I think this could be done by borrowing from the rule for typedef-whitespace but I haven't looked into it extensively.

@rhys-vdw
Copy link
Author

We've now solved this issue by handing all aesthetic issues with prettier and tslint-config-prettier.

@JoshuaKGoldberg
Copy link
Contributor

Since this is already in tslint-eslint-rules and the OP has otherwise solved the issue, closing this thread for housekeeping purposes. Thanks!

Relevant discussion around where these kinds of formatting rules should live: #628

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

6 participants