-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[EsLint] Add comma-dangle rule #14631
Conversation
I can't select everyone in kibana as a reviewer, but I'd appreciate all eyes on this. |
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.
Can you add a separate commit with all the changes too? Just to see the impact this has. I'm not against this, but if it touches every file in the repo it might be a bit too much, as it might cause tons of merge problems with our ~100 PRs (or maybe there's a simple way to solve that? I haven't found a good solution before, but haven't thought too much about it)
@archanid If you want to commit the changes before publishing the package, you can do what I did, which was to just copy/paste the config into the |
Replacing the folder in |
|
Well, sure, if you want to be all smart about it. |
Cool, yeah I've been sitting on this for a while. I'll do that and ping when it's ready. |
I think I'll abandon this in favor of using a prettier rule for this. |
Adds a comma-dangle rule, which you can read about.
Options:
Set it to
only-multiline
.The only sane options are
only-multiline
andalways-multiline
. I'd be good withalways-multiline
, but it is a bit more strict, as there will be errors if there are no trailing commas on multiline arrays, objects, imports, and exports. However, with--fix
, there's no issue with being bold and going withalways-multiline
. I just picked one. If people feel strongly and want to go withalways-multiline
, I'd be down, yo.Functions caveat:
There's a setting for
functions
, which is recommended only if you're writing in ES2017+, which we are. This is because:However, if I simply declare the one-liner string option:
I think this means eslint will set
"functions": "ignore"
in the rule. The explanation in the linked docs is hard to interpret. See:I think this is even if you set the string option to something other than
never
, as in the example documentation. So to forcefunctions
to be not-ignored, I think you have to use the object option (as I have in the PR), and specify what you want forfunctions
.If we prefer to ignore the functions, it means stuff like this could be annoying in diffs and code reviews. Code that requires multiline args for function declarations and invocations, i.e.:
So I propose handling functions just like we do everything else, either the
only-
oralways-multiline
.Discuss.