Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 924 Bytes

no-dangle.md

File metadata and controls

46 lines (34 loc) · 924 Bytes

no dangle

Trailing commas in object literals are valid according to the ECMAScript 5 (and ECMAScript 3!) spec, however IE8 (when not in IE8 document mode) and below will throw an error when it encounters trailing commas in JavaScript.

var foo = {
    bar: "baz",
    qux: "quux",
};

Rule Details

This rule is aimed at detecting trailing commas in object literals. As such, it will warn whenever it encounters a trailing comma in an object literal.

The following are considered warnings:

var foo = {
    bar: "baz",
    qux: "quux",
};

foo({
  bar: "baz",
  qux: "quux",
});

The following are okay and will not raise warnings:

var foo = {
    bar: "baz",
    qux: "quux"
};

foo({
  bar: "baz",
  qux: "quux"
});

When Not To Use It

If your code will not be run in IE8 or below (a NodeJS application, for example) and you'd prefer to allow trailing commas, turn this rule off.