Giter Club home page Giter Club logo

coffeelint-min-colon-spacing's Introduction

Coffeelint - Minimum Colon Spacing

Validate a minimum spacing left and right of a colon assignment

Description

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.

Installation

[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.

Usage

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"
}

Example

This code will lint without errors:

class TestClass

  foo : ->
    bar()

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

But this will fail:

class TestClass

  foo:->
    console.log("Oh no! I have linting errors.")

Configuration

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

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

License

MIT ยฉ scalable minds

coffeelint-min-colon-spacing's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

shyp

coffeelint-min-colon-spacing's Issues

Coffeelint dependency out of date

aallison@upbringgrain-lm corazon (master)*$ coffeelint -v
1.6.1
aallison@upbringgrain-lm corazon (master)*$ sudo npm install -g coffeelint-newline-after-function
npm ERR! peerinvalid The package coffeelint does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants coffeelint@~1.3
npm ERR! peerinvalid Peer [email protected] wants coffeelint@~1.1

npm ERR! System Darwin 13.4.0
npm ERR! command "/Users/aallison/.nvm/v0.10.32/bin/node" "/Users/aallison/.nvm/v0.10.32/bin/npm" "install" "-g" "coffeelint-newline-after-function"
npm ERR! cwd /Users/aallison/Workspace/growth/corazon
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/aallison/Workspace/growth/corazon/npm-debug.log
npm ERR! not ok code 0

This doesn't seem to work

If I validate this code against the current master

    data =
      userId:   req.currentUserId
      lat:      req.param 'lat' # optional
      lng:      req.param 'lng' # optional

set left to 0, and right to 1, I get the following error

โœ— #47: Colon assignment without proper spacing. Incorrect spacing around column 12.
Minimum Expected left: 0, right: 1.
Got left: 0, right: 3.

This seems incorrect, surely 1 is less than 3?

Furthermore, if I set right to a high value like 20, it works just fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.