Skip to content

ESLint plugin to optional require spaces or no spaces before and after commas

Notifications You must be signed in to change notification settings

greggman/eslint-plugin-optional-comma-spacing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

eslint-plugin-optional-comma-spacing

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

longest.id         = Math.max(longest.id        , game.gameId.length);
longest.numPlayers = Math.max(longest.numPlayers, game.numPlayers.toString().length);
longest.name       = Math.max(longest.name      , game.name.length);

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

About

ESLint plugin to optional require spaces or no spaces before and after commas

Resources

Stars

Watchers

Forks

Packages

No packages published