-
Notifications
You must be signed in to change notification settings - Fork 47
Trailing comma #67
Comments
I think that that would only accentuate the possible confusion with functions. I think we shouldn't make the import syntax look more like function calls than it already does, since it's not a function call, especially by allowing a trailing comma where it's impossible to add something after the comma. Code formatters are automatic, they shouldn't need too much help; developers need more help because they're humans and potential confusion should be reduced. A good editor with syntax highlighting should highlight the import syntax different from function syntax. |
Agreed. |
However, the intention was to eventually allow a second “argument” - at which point, a trailing comma in the first argument would have to be allowed. The transition would be awkward - it’d be better to allow it now than add it later.
|
I would say that |
@raulsebastianmihaila what i mean is, let’s say next year we allow a second argument in import(), for providing metadata or something (not relevant here). Suddenly, it would become valid to have a trailing comma after the first argument, because a second is optional - and people would likely want to enforce the comma-dangle eslint rule, which would mean they’d have to go in and add (or autofix) the trailing comma everywhere. In other words, the entire point of having a trailing comma (from a style POV) is to keep diffs smaller when you need to later add an item to the list - ie, to avoid having to add the comma in order to add the item. (I agree there’s no parsing advantage or disadvantage either way) |
I think most programmers think It's a bit like Technically, we could also make Of coz it's not a good idea to repeat the mistake of introducing confusing direct/indirect call semantics. But I think it's ok to make the direct call syntax more consistent --- allow trailing comma in |
If As is, it appears that its authors wanted it to syntactically appear as a function. |
Currently it is not allowed to have a trailing comma inside the import call, but maybe it would be nice to be able to do that.
The reasons for trailing commas are usually about adding/removing elements from a multiline list of elements. This obviously does not apply here as import always has one argument, but it still would be nice to have this possibility for the sake of consistency with function calls.
Especially for code formatters I can see that it would be a little bit easier to treat import calls the same as function calls.
Was there already a decision on this and what's your opinion on this?
Should I try to create a PR?
The text was updated successfully, but these errors were encountered: