optionally require spaces before or after commas

Downloads in past


000.0.49 years ago9 years agoMinified + gzip package size for eslint-plugin-optional-comma-spacing in KB


Build Status
ESLint rule for optionally requiring spaces before or after commas.

Why Use It

You'd like to optionally require spaces before or after commas. For example if you use the standard comma-spacing this will fail         = Math.max(        , game.gameId.length);
longest.numPlayers = Math.max(longest.numPlayers, game.numPlayers.toString().length);       = Math.max(      ,;
I wanted those spaces before the commas to be optional hence this plugin.
This is just a clone of the standard comma-spacing rule. The difference is where as the comma-spacing rule only has before: true | false and after: true | false this one has before: undefined | true | false and after: undefined | true | false. Both rules default to undefined so you can therefore do this
'eslint-plugin-optional-comma-space': [2, {'after': true}],
Which will require spaces after a comma but before a comma they are optional.

Further Reading