29 lines
805 B
Plaintext
29 lines
805 B
Plaintext
== Why is this an issue?
|
|
|
|
Modern browsers ignore unneeded, trailing commas, so there are no negatives to having them unless you're supporting an IE 8 application. Since they make adding new properties simpler, their use is preferred. This rule raises an issue when the last item in a multiline construct (array or object literal, import or export statement, function declaration or call) does not end with a trailing comma and does not lie on the same line as the closing curly brace, bracket or parenthesis.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,text]
|
|
----
|
|
var joe = {
|
|
fname: "Joe",
|
|
lname: "Smith" // Noncompliant
|
|
};
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,text]
|
|
----
|
|
var joe = {
|
|
fname: "Joe",
|
|
lname: "Smith", // OK
|
|
};
|
|
|
|
var joe = {
|
|
fname: "Joe",
|
|
lname: "Smith"}; // OK
|
|
----
|