tools: eslint object curly spacing#14162
tools: eslint object curly spacing#14162sebdeckers wants to merge 6 commits intonodejs:masterfrom sebdeckers:eslint-template-curly-spacing
Conversation
IMHO |
|
We should leave out changes to upstream packages (e.g. files in tools/icu). |
.eslintrc.yaml
Outdated
|
/cc @nodejs/release |
Just adding commits is the best way for us to review. Commits will probably be squashed while landing. |
.eslintrc.yaml
Outdated
There was a problem hiding this comment.
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.
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.
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! |
vsemozhetbyt
left a comment
There was a problem hiding this comment.
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. |
TimothyGu
left a comment
There was a problem hiding this comment.
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 |
|
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 <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>
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>
|
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 <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>
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>
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>
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>
|
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