Validate a minimum spacing left and right of a colon assignment
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Coffeelint - Minimum Colon Spacing

Validate a minimum spacing left and right of a colon assignment


This CoffeeLint plugin verifies whether or not a minimum amount of spacing is to the left and/or right of a colon assignment. It is based on the 'colon_assignment_spacing' rule but is less strict by only enforcing a minimum spacing and not an excat amount. This can come in handy when you have files with object assignments where the colon are vertically aligned. See the Router class in the examples part.


[sudo] npm install -g coffeelint-newline-after-function

Note: Right now a Coffeelint plugin cannot be installed as a project dependency and must be installed globally. Perhaps this will be improved in a future version of Coffeelint. If you would like to track progress on this enhancement head over here.


Insert the below configuration into coffeelint.json that you use for linting your scripts:

"min_colon_spacing": {
    "module": "coffeelint-min-colon-spacing",
    "spacing": {
      "left" : 1,
      "right" : 1
    "level": "error"


This code will lint without errors:

class TestClass

  foo : ->

class Router
  routes :
    "/main"            : "main"
    "/dashboard/users" : "dashboard
    "/settings"        : settings

But this will fail:

class TestClass

    console.log("Oh no! I have linting errors.")


The only configuration option specific to this plugin is the spacing property. Change the "left" or "right" property to the number of spaces that you like to be inforced.

By default, Coffeelint will report errors if this rule is not satisfied. You may want to relax this by setting the level to warn in your configuration.


Credits go to Ian McNally whose 'colon_assignment_spacing' rule serves as the basis for this fork.


MIT © scalable minds