const {
onEnter,
refField,
meta,
input: { onChange, ...remainingInputProps },
...remainingProps
} = this.props;
with tslint.json configuration:
{
"extends": ["tslint:latest", "tslint-react"]
}
Missing trailing comma (trailing-comma) error is raised on object rest.
Missing trailing comma (trailing-comma) error should not be raised on object rest.
@charles-salmon I think this is (or has been) a topic of discussion already.
@aervin Apologies, I missed that. It looks as though the last issue was closed on the basis that it is _valid_ to use a comma after an object rest in TypeScript, so perhaps it's not very fitting for this to have been raised as a Bug Report.
Stylistically, however, I'm now convinced that it makes little sense to enforce that an object rest _must have_ a comma. The point of the trailing-comma rule is to produce clean diffs. This enforcement has no impact on producing clean diffs, while it creates a difference from ES6 specification. Is this a discussion worth revisiting?
@charles-salmon I took a look at the docs and found this: To align this rule with the ECMAScript specification that is implemented in modern JavaScript VMs, there is a third option esSpecCompliant. Set this option to true to disallow trailing comma on object and array rest and rest parameters. Could this solve the problem? I've never tried it myself.
@aervin Perfect! That was exactly what I was after. Thank you for your help.
Since TypeScript now disallows commas after an object rest param, I submitted a followup: #4172.
Most helpful comment
@aervin Perfect! That was exactly what I was after. Thank you for your help.