Enable `object-curly-spacing` and `comma-dangle` on the ESLint codebase
See original GitHub issueI think it would be nice to enable object-curly-spacing
and comma-dangle
on the ESLint codebase. A lot of our code is inconsistent about this (sometimes it’s even inconsistent in the same object, e.g. { message: "foo"}
).
I ran the rules on the existing codebase to determine which options we should use:
$ eslint --rule 'comma-dangle:[error, never]' 'lib/**/*.js' 'tests/**/*.js' 'bin/**/*.js' --rulesdir lib/internal-rules/ | grep 'problems'
✖ 227 problems (227 errors, 0 warnings)
$ eslint --rule 'comma-dangle:[error, always-multiline]' 'lib/**/*.js' 'tests/**/*.js' 'bin/**/*.js' --rulesdir lib/internal-rules/ | grep 'problems'
✖ 13251 problems (13251 errors, 0 warnings)
It looks like we almost always omit the trailing comma, so I think we should enable comma-dangle: never
.
$ eslint --rule 'object-curly-spacing: [error, always]' 'lib/**/*.js' 'tests/**/*.js' 'bin/**/*.js' --rulesdir lib/internal-rules/ | grep 'problems'
✖ 9272 problems (9272 errors, 0 warnings)
eslint --rule 'object-curly-spacing: [error, never]' 'lib/**/*.js' 'tests/**/*.js' 'bin/**/*.js' --rulesdir lib/internal-rules/ | grep 'problems'
✖ 16060 problems (16060 errors, 0 warnings)
It looks like we usually include curly spacing, so I think we should enable object-curly-spacing: always
.
I’ll probably create a PR to add these in the next few days if no one has any objections. I just wanted to create this issue first to give some advance notice in case anyone is against enabling these rules, since it seems like we generally end up merging PRs like that fairly quickly to avoid merge conflicts.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:9 (9 by maintainers)
Sounds like the only thing left to hash out here is how we want to configure
comma-dangle
. Seems like most of us would be fine with"never"
or"always-multiline"
. Since we have one vote strictly in favor of"never"
, I propose we go with"never"
(which is what our codebase currently follows anyway).Makes sense 👍 On Tue, Jan 10, 2017 at 4:27 AM Kai Cataldo notifications@github.com wrote: