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

whitespace rule enhancements #628

Closed
rcchen opened this issue Sep 1, 2015 · 7 comments
Closed

whitespace rule enhancements #628

rcchen opened this issue Sep 1, 2015 · 7 comments
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier P2 Status: Needs Proposal Type: Rule Suggestion

Comments

@rcchen
Copy link

rcchen commented Sep 1, 2015

Create some sort of rule for maximum spacing between characters in a single line I think. For example,

public foo { // one space, all good

public foo  { // two spaces, this should be flagged
@adidahiya
Copy link
Contributor

This should be an extension of the current whitespace rule, perhaps in the form of a "check-brace" option which checks for only 1 space before a {.

@adidahiya adidahiya changed the title New rule: max-spacing whitespace rule enhancements Sep 1, 2015
@glen-84
Copy link
Contributor

glen-84 commented Jan 19, 2016

@adidahiya It's not only for braces. Right now this is valid:

        if     (1)     {
            let x;
        }    else                 {
            let x;
        }

That looks quite awful. Perhaps each check-* should have a spaces integer which controls the number of spaces that must be used.

However, I would imagine that in 99% of cases, a single space is used/required, so another option would be to just add a single-spaces "global" option to enforce a single space in all cases except before an equals sign (as people often align assignments).

In a perfect world, it would be able to keep track of groups of assignments and report on misalignment, but that may not be simple.

@myitcv
Copy link
Contributor

myitcv commented Jan 19, 2016

@rcchen @glen-84 rather than enforcing spacing rules (indeed formatting rules in general) by hand, you might be interested in tsfmt. It automatically formats code for you.

@unional
Copy link
Contributor

unional commented Mar 25, 2016

named-function

function init() {}

// vs
function init () {}

@unional
Copy link
Contributor

unional commented Mar 25, 2016

anonymous-function:

function() {}

// vs
function () {}

@glen-84
Copy link
Contributor

glen-84 commented Jul 24, 2016

@myitcv Thanks for the suggestion, but I'd prefer to use linting in this case.

@JoshuaKGoldberg
Copy link
Contributor

Closing per #4534. Thanks for the discussion folks!

@JoshuaKGoldberg JoshuaKGoldberg added the Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier label Jul 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier P2 Status: Needs Proposal Type: Rule Suggestion
Projects
None yet
Development

No branches or pull requests

6 participants