Reputation: 1118
I'm going through react-redux boilerplate
there is a code there
function mapDispatchToProps(dispatch) {
return {
dispatch,
};
}
I wondered why a comma after dispatch is required? i.e. when i remove comma eslint hints an error:
Insert ',' eslint(prettier/prettier)
I played it with babeljs.io either with/without comma the code is converted into
function mapDispatchToProps(dispatch) {
return {
dispatch: dispatch
};
}
It does not matter a lot but to understand why eslint forces me to put the comma..
Upvotes: 0
Views: 94
Reputation: 943142
Trailing commas simplify adding and removing items to objects and arrays, since only the lines you are modifying must be touched. Another argument in favor of trailing commas is that it improves the clarity of diffs when an item is added or removed from an object or array:
Upvotes: 2