-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tools: eslint object curly spacing #14162
Conversation
IMHO |
We should leave out changes to upstream packages (e.g. files in tools/icu). |
.eslintrc.yaml
Outdated
@@ -135,6 +135,7 @@ rules: | |||
}] | |||
no-tabs: error | |||
no-trailing-spaces: error | |||
object-curly-spacing: ["error", "always"] |
There was a problem hiding this comment.
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
/cc @nodejs/release |
Just adding commits is the best way for us to review. Commits will probably be squashed while landing. |
@@ -135,16 +135,17 @@ rules: | |||
}] | |||
no-tabs: error | |||
no-trailing-spaces: error | |||
object-curly-spacing: [error, always] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
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. |
If the rule remains as it is now in the main |
@vsemozhetbyt Done. Thank you for the suggestion! |
There was a problem hiding this 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).
I'm thinking the main commit should be split to 5 (since each directory have different backporting concern):
Although this should be a 0 semantic change, and could be backported as a whole. |
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. |
I think as they're just using |
@sebdeckers The name of this PR should say |
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... |
@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. |
There was a problem hiding this 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.
The other side of the argument — setting: object-curly-spacing: [error, never] results in 3646 errors in 517 files |
There was a problem hiding this 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
Rebased and delinted recent commits. |
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 |
PR-URL: nodejs#14162 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#14162 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extra sanity test on |
@sebdeckers This doesn’t land cleanly on 8.x; if you can, please follow the guide and raise a backport PR. |
PR-URL: nodejs#14162 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#14162 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #14162 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #14162 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
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. |
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), orvcbuild test
(Windows) passes (@sebdeckers: works on my machine 😅)Affected core subsystem(s)
tools