🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

eslint-plugin-require-trailing-comma

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-require-trailing-comma

Require trailing comma

0.0.1
latest
Source
npm
Version published
Weekly downloads
351
45.04%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

eslint

FAQs

Package last updated on 11 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts