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

tools: enable no-extra-semi rule in eslint #2205

Closed
wants to merge 2 commits into from

Conversation

targos
Copy link
Member

@targos targos commented Jul 19, 2015

This CL adds two rules:

no-extra-semi

  • Removed obvious extra semicolons
  • Had to change some loops to add an empty body

semi-spacing (removed)

This one is up for discussion because the changes I had to make feel wrong to me.
For instance in try {fs.rmdirSync(tmp(folder)); } catch (ex) {} the space isn't really improving readability. Maybe it would better if we added a space as well at the beginning of the try block, but I can't find a rule for that.
Because of that I would prefer to explicitly disable this rule in .eslintrc but it is the one that enforces spaces in code like for(let i = 0; i < x; i++) so we'd lose that check.

@thefourtheye thefourtheye added test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory. labels Jul 19, 2015
@silverwind
Copy link
Contributor

Oh damn, looks like we were working on this at the same time (#2207).

@silverwind
Copy link
Contributor

Regarding semi-spacing: I use it personally in my projects, but didn't see the necessity because the extra space looks "wrong" in a try {something; } to me. I see some value in the spacing of a for loop, maybe we should propose an option like forOnly to that rule.

Regarding bodyless loops: I see you wenn with a {} as a simple workaround to the rule bug. It's one way of handling it, but I feel the refactoring I did in the two lib cases might help make them more readable.

@silverwind
Copy link
Contributor

Closed #2207 in favor of this. Maybe you can take a hint from the few changes I did differently.

@cjihrig
Copy link
Contributor

cjihrig commented Jul 19, 2015

try {something; } does look a little... not quite right. I'd say either turn it off or add a space at the beginning as well.

@silverwind
Copy link
Contributor

ESLint already fixed the issue with the bodyless loops in eslint/eslint@25f14ae, which will eliminate 7 changes in this diff. I'd say let's wait until the ESLint 1.0 is out, which shouldn't be too far off, and then revisit this PR.

@targos
Copy link
Member Author

targos commented Jul 19, 2015

OK then let's wait for v1.0. Good job on making them fix this issue so fast !

@@ -9,7 +9,7 @@ assert(Array.isArray(start));

// busy-loop for 2 seconds
var now = Date.now();
while (Date.now() - now < 2000);
while (Date.now() - now < 2000) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style shouldn't actually be enforced. You can do useful things inside while(); and for(;;); statements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what the mentioned ESlint bugfix is about: bodyless loops :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted those changes

@Fishrock123
Copy link
Contributor

@targos @joaocgreis @thefourtheye

I forgot to mention in the onboarding session: We try to avoid purely style changes as much as possible. This is mostly because it makes git blame harder to understand.

Some concessions can be made for bringing the style to be more cohesive though.

@@ -46,6 +48,8 @@ rules:
comma-spacing: 2
## put semi-colon
semi: 2
## disable semi-spacing
semi-spacing: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well remove it completely ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all right

@targos
Copy link
Member Author

targos commented Jul 24, 2015

I started to work on the eslint update on my fork, using the latest rc2.
We have a problem because it is reporting 589 indent errors. Apparently it doesn't like variable name alignment like we do here.
I found no mention of that in the migration guide or the docs. There are a few bug fixes for this rule, maybe we are relying on the wrong behavior :(

/cc @silverwind @yosuke-furukawa

@yosuke-furukawa
Copy link
Member

No rule settings to avoid the errors?? If so, we need to suggest the settings to eslint

@Fishrock123
Copy link
Contributor

@targos could you either report that to them, or pull one of the maintainers in here? Thanks. :)

@targos
Copy link
Member Author

targos commented Jul 24, 2015

@Fishrock123 will do

@cjihrig
Copy link
Contributor

cjihrig commented Jul 24, 2015

This issue might be relevant - eslint/eslint#3139. Looks like it was fixed yesterday.

@targos
Copy link
Member Author

targos commented Jul 25, 2015

Still present in rc-3.

eslint/eslint#3164

@silverwind
Copy link
Contributor

We could do

var x;
var y;
var z;

instead of

var x,
    y,
    z;

Its easier to handle because you don't have to think whether to put a comma or semicolon on each line, but I fear a 500+ line diff might be too much noise. Another argument against the second style is that the 4-character alignment doesn't work anymore with const as opposed to var.

Any thoughts on this?

@Fishrock123
Copy link
Contributor

Any thoughts on this?

That'd be so purely style changes that it wouldn't be approved. That's not even a lint fixing change really. Let's just wait until it gets fixed.

@silverwind
Copy link
Contributor

Looks the error on 4-space alignment is intended and I think I have to agree that strictly speaking it's an violation of 2-space indent. We could either go with disabling the rule, doing my suggestion above, or do a ugly

var a,
  b,
  c;

I think we should consider my suggestion, even if the diff is huge. One {const,let,var} per variable is found in style guides like https://github.com/airbnb/javascript#13.2.

@targos
Copy link
Member Author

targos commented Jul 27, 2015

I also don't want to change so many lines just to content the linter.
The style that we are using (name alignment instead of 2 spaces) is nice and should be allowed.
It appears that the change in eslint is considered a bug fix so it is unlikely that it will change for 1.0

@targos
Copy link
Member Author

targos commented Jul 27, 2015

I'm -1 for the ugly fix.
If we want to make a huge diff, let's be explicit and put the var keyword.

@Fishrock123
Copy link
Contributor

I'm for var per line if we'd have to change the indentation to two spaces.

I'm against doing either though, the diff would probably be huge... Is it unavoidable now?

@silverwind
Copy link
Contributor

Looking through the 592 indent errors reported by rc-3, it looks like some of these are unrelated to the var style and seem bugged (especially cases after an if condition). We might be able to reduce the number of changes to like 300-400 lines (note, this includes test), but that indentation style looks to be pretty common.

@Fishrock123
Copy link
Contributor

@silverwind any idea why they didn't catch them before?

I'd really prefer to have an exception rule to this tbh.

@targos targos changed the title tools: enable semicolon-related rules in eslint tools: enable no-extra-semi rule in eslint Jan 15, 2016
@targos
Copy link
Member Author

targos commented Jan 15, 2016

Done, although that's really a purely stylistic change.

@silverwind
Copy link
Contributor

Of course it is, but we keep getting PRs for it ;)

@cjihrig
Copy link
Contributor

cjihrig commented Jan 15, 2016

The changes themselves LGTM. This is definitely churn though :-(

@silverwind
Copy link
Contributor

LGTM. Yeah it's a bit of churn, but these are mostly on the closing bracket of functions, so shouldn't interfere with git blame that much.

@silverwind
Copy link
Contributor

silverwind pushed a commit that referenced this pull request Jan 16, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
silverwind pushed a commit that referenced this pull request Jan 16, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@silverwind
Copy link
Contributor

Thanks! Landed in 162e16a and 0ec093c.

@silverwind silverwind closed this Jan 16, 2016
@targos targos deleted the no-extra-semi branch January 16, 2016 19:36
evanlucas pushed a commit that referenced this pull request Jan 18, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
evanlucas pushed a commit that referenced this pull request Jan 18, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@Trott
Copy link
Member

Trott commented Feb 16, 2016

Should this go in LTS? (My feeling is it should.)

@rvagg
Copy link
Member

rvagg commented Feb 16, 2016

fine by me, kill those extra semi's with fire, adding lts-watch

MylesBorins pushed a commit that referenced this pull request Feb 17, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
MylesBorins pushed a commit that referenced this pull request Feb 17, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
MylesBorins pushed a commit that referenced this pull request Feb 18, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
MylesBorins pushed a commit that referenced this pull request Feb 18, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@MylesBorins MylesBorins mentioned this pull request Feb 18, 2016
MylesBorins pushed a commit that referenced this pull request Mar 2, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
MylesBorins pushed a commit that referenced this pull request Mar 2, 2016
PR-URL: #2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
PR-URL: nodejs#2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
PR-URL: nodejs#2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants