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

Missing whitespace style rules #3

Open
7 of 8 tasks
Krinkle opened this issue Sep 12, 2016 · 10 comments
Open
7 of 8 tasks

Missing whitespace style rules #3

Krinkle opened this issue Sep 12, 2016 · 10 comments

Comments

@Krinkle
Copy link
Member

Krinkle commented Sep 12, 2016

The following aspects of our coding style are not yet enforced by this configuration.

  • Unexpected space in empty parameter list or other parenthesis.
- function foo( ) {}
+ function foo() {}
  • When a keyword requires spacing, one space must be used. (Not a line break)
- } else
- if {
+ } else if {

  // Fixed by no-multi-spaces
- } else  if {
+ } else if {

  // Fixed by no-multi-spaces
- if  ( true ) {}
+ if ( true ) {}
  • One space before blocks (e.g. no other forms of whitespace).
  // Reject: A tab
- if ( true )   {
+ if ( true ) {
  }
  • [no-multi-spaces] One space before blocks (e.g. not multiple).
  // Reject: Two spaces
- if ( true )   {
+ if ( true )  {
  }
  • [no-multi-spaces] One space required inside parenthesis (e.g. not multiple).
- function foo( y, x  ) {
- function foo(  y, x ) {
+ function foo( y, x ) {

- if (  true ) {}
- if ( true  ) {}
+ if ( true ) {}
  • [no-multi-spaces] One space required after comma.
- function foo( y,  x ) {
+ function foo( y, x ) {
  • [no-multi-spaces] When an operator requires spacing, then one space must be used.
- var foo  = x;
- var foo =  x;
+ var foo = x;

  // And other assignment operators
- foo  += x;
- foo +=  x;
+foo += x;

 // And other unary, multiplicative, additive, and conditional operators 
- var foo = x  + y;
- var foo = x +  y;
- var foo = x + y;

- var foo = x  ? y : z;
- var foo = x ? y  : z;
- var foo = x ? y :  z;
+ var foo = x ? y : z;

  // And other relational, equality, and conditional operators
- if ( true  && false ) {}
- if ( true &&  false ) {}
+ if ( true && false ) {}

- if ( true  !== false ) {}
- if ( true !==  false ) {}
+ if ( true !== false ) {}
  • [no-multi-spaces] One space required when declaring variables. (A line break should be allowed.)
- var  foo = x;
+ var foo = x;
var
    foo = x,
    bar = y;
Krinkle added a commit that referenced this issue Sep 13, 2016
@jdforrester
Copy link
Member

Worth putting in a series of failing test cases to ensure we're testing what we think we're testing? Or too much?

@jdforrester
Copy link
Member

Of the two partial outstanding cases:

- } else
- if {
+ } else if {

… and …

- if ( true )   {
+ if ( true ) {

These will require upstream changes, from what I can see.

@edg2s
Copy link
Member

edg2s commented Nov 29, 2016

The latter is eslint/eslint#7621

@Krinkle
Copy link
Member Author

Krinkle commented Apr 24, 2017

eslint/eslint#7621 has been resolved.

@edg2s
Copy link
Member

edg2s commented Jul 2, 2018

What is remaining to do on this task, and are any issues upstream issues?

@Krinkle
Copy link
Member Author

Krinkle commented Jul 3, 2018

With eslint/eslint#7621 resolved, I've confirmed on latest master that the following is now rejected (already covered by our test fixture as well).

  • One space before blocks
- if ( true )   {
+ if ( true ) {

However, the following from the task description not covered by a test fixture and be a problem still.

  • When a keyword requires spacing, one space must be used. (Not a line break)
- } else
- if {
+ } else if {

@edg2s
Copy link
Member

edg2s commented Jul 7, 2018

Has this been filed upstream? I couldn't see anything with a quick search, but they have a lot of open issues.

@jdforrester
Copy link
Member

Has this been filed upstream?

AFAICS, No.

@edg2s
Copy link
Member

edg2s commented Feb 18, 2019

Another issue:

1: /*tab*/if (
2: /*tab*//*tab*/foo === bar &&
3: /*Nspaces*/quux === whee
4: /*tab*/) { ...

The tabs on line 2 are linted and enforced, however anything goes on line 3...

@jdforrester
Copy link
Member

@Krinkle, do you want to file these issues upstream? I'm not sure I'd use the correct terms.

@jdforrester jdforrester changed the title Missing style rules Missing whitespace style rules Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants