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: eslint object curly spacing #14162

Closed
wants to merge 6 commits into from
Closed

tools: eslint object curly spacing #14162

wants to merge 6 commits into from

Conversation

sebdeckers
Copy link
Contributor

@sebdeckers sebdeckers commented Jul 11, 2017

As per suggestion by @jasnell, this is a de-facto house style. Enabling this rule makes it de-jure.

Not sure how the commit message guideline would make me label this commit, so I've left it as tools: even though the (hopefully inert) lint fixes touch other areas.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes (@sebdeckers: works on my machine 😅)
  • commit message follows commit guidelines (as per comment below)
Affected core subsystem(s)

tools

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Jul 11, 2017
@refack
Copy link
Contributor

refack commented Jul 11, 2017

Not sure how the commit message guideline would make me label this commit, so I've left it as tools: even though the (hopefully inert) lint fixes touch other areas.

IMHO tools: is the right prefix

@mscdex
Copy link
Contributor

mscdex commented Jul 11, 2017

We should leave out changes to upstream packages (e.g. files in tools/icu).

refack
refack previously approved these changes Jul 11, 2017
.eslintrc.yaml Outdated
@@ -135,6 +135,7 @@ rules:
}]
no-tabs: error
no-trailing-spaces: error
object-curly-spacing: ["error", "always"]
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for " in yaml

@mscdex mscdex added the tools Issues and PRs related to the tools directory. label Jul 11, 2017
@refack refack dismissed their stale review July 11, 2017 01:39

I need to take another look

@refack
Copy link
Contributor

refack commented Jul 11, 2017

/cc @nodejs/release

@sebdeckers
Copy link
Contributor Author

Thanks for the super quick feedback! ❤️
@mscdex I've undone the change and added tools/icu to .eslintignore
@refack cleaned up the quotes

Q: Should I squash the commits, either while pushing changes in response to reviews, or once the changes have been approved?

@refack
Copy link
Contributor

refack commented Jul 11, 2017

Q: Should I squash the commits, either while pushing changes in response to reviews, or once the changes have been approved?

Just adding commits is the best way for us to review. Commits will probably be squashed while landing.
Conflicts might arise before this PR lands, in that case you'll probably need to rebase and fix the conflicts.

@@ -135,16 +135,17 @@ rules:
}]
no-tabs: error
no-trailing-spaces: error
object-curly-spacing: [error, always]
Copy link
Member

Choose a reason for hiding this comment

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

You can reduce the churn slightly and conform more closely to the house style by doing this instead:

  object-curly-spacing: [error, always, {objectsInObjects: false}]

That flags 2144 problems in the current code base, instead of the 2183 flagged with the PR as it is. That's not a huge reduction, but every little bit helps to make backporting less awful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

99% of these changes were made using eslint --fix automatically. Except for ~30 cases where the insertion of spaces then caused the line to grow longer than 80 characters, which I cleaned up manually following my own stylistic judgement and ensuring eslint passes.

Copy link
Member

Choose a reason for hiding this comment

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

In general it's useful to do the automatic ones as one commit, and then the manual ones as a separate one. They'll get squashed on landing, but it means people can review the ones that weren't just an eslint --fix (which are probably the more interesting ones).

@mscdex
Copy link
Contributor

mscdex commented Jul 11, 2017

Perhaps we should also add 'deps/' to .eslintignore (assuming that will match everything in deps).

@Trott
Copy link
Member

Trott commented Jul 11, 2017

Perhaps we should also add 'deps/' to .eslintignore (assuming that will match everything in deps).

We don't run ESLint on the deps directory so there's no need to ignore files in it. We explicitly run it on benchmark, doc, lib, tools, and test directories only.

@vsemozhetbyt
Copy link
Contributor

If the rule remains as it is now in the main .eslintrc.yaml, you can delete it from the doc/.eslintrc.yaml.

@sebdeckers
Copy link
Contributor Author

@vsemozhetbyt Done. Thank you for the suggestion!

Copy link
Contributor

@vsemozhetbyt vsemozhetbyt left a comment

Choose a reason for hiding this comment

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

LGTM if full CI is green when unblocked (in case I've missed something).

@refack
Copy link
Contributor

refack commented Jul 11, 2017

I'm thinking the main commit should be split to 5 (since each directory have different backporting concern):

  1. /benchmark/
  2. /lib/
  3. /test/
  4. /tools/
  5. .eslintrc.yamls

Although this should be a 0 semantic change, and could be backported as a whole.
But @nodejs/release should give the final word

@Trott
Copy link
Member

Trott commented Jul 11, 2017

I'm thinking the main commit should be split to 5

I'm not saying it's better or worse, but in the past, we've often done it as two commits: One for the code updates, and one for enabling the rule in eslintrc.

@gibfahn
Copy link
Member

gibfahn commented Jul 11, 2017

I'm thinking the main commit should be split to 5 (since each directory have different backporting concern):

I think as they're just using eslint --fix they'll just be backported by backporting the rule and then running eslint --fix again, so in this specific case I don't think it's necessary.

@vsemozhetbyt
Copy link
Contributor

@Trott
Copy link
Member

Trott commented Jul 11, 2017

@sebdeckers The name of this PR should say object curly spacing rather than template curly spacing. Or am I mistaken?

@sebdeckers sebdeckers changed the title tools: eslint template curly spacing tools: eslint object curly spacing Jul 12, 2017
@evanlucas
Copy link
Contributor

I think I'm -1 on this change. I wouldn't say the house style is to include spaces, especially if this requires 292 changes...

@sebdeckers
Copy link
Contributor Author

@evanlucas I didn't mean for this change to be about bikeshedding eslint rules. "House style" was quoted from the referenced comment; not my words. As for the high change count, I'd argue that proves the need for this option to be set one way or another.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

I'd like to standardize around array spacing too. The preferred style, I believe, is to not add spaces inside brackets.

@refack
Copy link
Contributor

refack commented Jul 13, 2017

I think I'm -1 on this change. I wouldn't say the house style is to include spaces, especially if this requires 292 changes...

The other side of the argument — setting:

object-curly-spacing: [error, never]

results in 3646 errors in 517 files

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

largely rubber stamp lgtm

@sebdeckers
Copy link
Contributor Author

Rebased and delinted recent commits.

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt
Copy link
Contributor

Linter fails:

test/parallel/test-fs-open-flags.js
  59:23  error  A space is required after '{'   object-curly-spacing
  59:70  error  A space is required before '}'  object-curly-spacing

test/parallel/test-internal-fs.js
  12:3   error  A space is required after '{'   object-curly-spacing
  12:59  error  A space is required before '}'  object-curly-spacing

refack pushed a commit to refack/node that referenced this pull request Jul 21, 2017
PR-URL: nodejs#14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
refack pushed a commit to refack/node that referenced this pull request Jul 21, 2017
PR-URL: nodejs#14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@refack
Copy link
Contributor

refack commented Jul 21, 2017

Landed in 6add5b3 bb29405

@refack refack closed this Jul 21, 2017
@refack
Copy link
Contributor

refack commented Jul 21, 2017

@addaleax
Copy link
Member

@sebdeckers This doesn’t land cleanly on 8.x; if you can, please follow the guide and raise a backport PR.

jasnell pushed a commit to jasnell/node that referenced this pull request Sep 20, 2017
PR-URL: nodejs#14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell added a commit to jasnell/node that referenced this pull request Sep 20, 2017
PR-URL: nodejs#14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell jasnell mentioned this pull request Sep 20, 2017
3 tasks
jasnell pushed a commit that referenced this pull request Sep 20, 2017
PR-URL: #14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell added a commit that referenced this pull request Sep 20, 2017
PR-URL: #14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Contributor

Since this touches so many files it would be really great to get a backport to v6.x to avoid future merge conflicts. Please follow this guide and raise a backport PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.