JSPM

eslint-plugin-require-trailing-comma

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 326
  • Score
    100M100P100Q96968F
  • License MIT

Require trailing comma

Package Exports

  • eslint-plugin-require-trailing-comma

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-require-trailing-comma) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

eslint-plugin-require-trailing-comma

ESLint rule for enforcing requiring trailing commas

Why Use It

You like consistency

Here is an array and object with consistent lines endings

var array = [
  1,
  2,
  3,
];

var object = {
  a: 1,
  b: 2,
  c: 3,
};

Here is an array and object with inconsistent lines endings

var array = [
  1,
  2,
  3
];

var object = {
  a: 1,
  b: 2,
  c: 3
};

Having consistent line endings means each line is independent. You can sort the lines, cut, copy, and paste the lines, add more lines, all without worrying about one line being different.

Why Not Use It

IE8 and before will barf.

Notes:

The default is to only require trailing comma on multi-line arrays and objects. Single line arrays and objects are ignored. use all to enforce even on single line arrays and objects as in

{
    "rules: {
        "require-trailing-comma/require-trailing-comma": [2, "all"],
    }
}

Further Reading