27 lines
777 B
Plaintext
27 lines
777 B
Plaintext
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
|
|
----
|