eslint-plugin-require-trailing-comma
v0.0.1
Published
Require trailing comma
Downloads
1,093
Maintainers
Readme
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
- http://eslint.org/