Avoid Trailing Commas In Object Or Array Literals

< 1 min read

Impact Area

Manageability

Severity

High

Affected Element

Lightning

Rule ID #

SF-0069

Impact #

Using trailing commas in object or array literals reduces code portability due to differences in how different browsers interpret these trailing commas.

Remediation #

Remove any trailing commas from object or array literal definitions.

Explanation #

When an array is defined with a trailing , for some browsers this is ok, but others could fail to process it. The solution is simply to remove the trailing (last) comma from the array definition.

Time to fix #

30 min

Original reference #

PMD: AvoidTrailingComma

Updated on March 21, 2025