Coder Social home page Coder Social logo

coffeelint's People

Contributors

7yl4r avatar asaayers avatar braddunbar avatar brysgo avatar clutchski avatar eventualbuddha avatar int3 avatar isakb avatar janpieper avatar jspiro avatar kryskruk avatar leostera avatar manuelschneider avatar mhart avatar misterdjules avatar mitar avatar mnquintana avatar mrmr1993 avatar nathanpalmer avatar plumlee avatar robhor avatar satook avatar sgentle avatar sinetheta avatar sjz avatar swang avatar szinsli avatar thomasf avatar zmbush avatar zolmeister avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffeelint's Issues

Invalid error

The code is valid:

    @collection
      .fetch()
      .done =>
        $button.removeAttr('disabled')
        @trigger 'sync'

or

[1, 2, 3]
  .map (a) ->
    a * 2
  .filter (a) ->
    a > 3

linter says:

17 Sep 03:46:56 - error: Linting of 'app/views/user/user_repo_sync_view.coffee' failed. error: indentation at line 27.Expected 2 got -2

Trailing semicolon not detected with Windows newlines

The following file with a Windows newline (CR+LF) after the semicolon passes trailing semicolon detection:

x = 5;

  V test.coffee

V Ok! » 0 errors and 0 warnings in 1 file

If I change to a Unix newline, I get:

     ? #1: Line contains a trailing semicolon.

? Lint! » 1 error and 0 warnings in 1 file

trailing spaces in comments

I think it would be great to ignore trailing whitespaces in comments.

Use-Case:
Coffeedoc uses Markdown, in markdown trailing whitespaces mean newline.

Maybe there's another way to force newlines with markdown? I'm quite new to it and would like the idea of not having trailing whitespaces.

If there's not - I think coffeelint should have a switch to turn the trailing-whitespaces check off for comments. Would that be OK?

CI support

Coffeelint should be CI-friendly.

It should return shell exit codes. In this case coffeelint can be integrated together with CI-servers.

Error for "Implicit Braces" check when defining class methods

I noticed that defining methods on a class seems to make cofeelint complain about "Implicit braces are forbidden" when the "implicit_braces" option is set to "error". Defining methods seems to actually have the same syntax as creating an object without braces, but it's different semantics when it comes right after a class declaration.

test.coffee

class Test
  method: ->
    "hello"

test.json

{
  "no_implicit_braces" : {
    "level" : "error"
  }
}

Output

  ✗ test.coffee
     ✗ #2: Implicit braces are forbidden.

✗ Lint! » 1 error and 0 warnings in 1 file

More ideas for better linter

https://github.com/polarmobile/coffeescript-style-guide should be followed with optional rules:

  • Check for using and, or, is, isnt not
    instead of &&, ||, ==, !=, !
  • More prohibitions:
    • unless-else. Should be rewritten as if-else to be much clearer
    • Standalone @, this.prop instead of @prop (gh-18)
    • Function declaration with round braces and no args (() ->)
    • Using double strings for non-interpolated content
    • underscore_case indentifiers
  • Add more strict whitespace rules. Stuff that will always need to use one space before and after:
    • Function declarations
    • Operators
    • Arguments (a, b, c)

exit code

when error encontered exits with 1, so that coffeelint can be used in scripts

website feature request: continuous linting

There should be no need to press a button to perform the linting. Every keypress/change should trigger a re-linting. Also, there's currently no visual cue that the linting was performed when the lint status remains the same.

Pipe in coffeescript

I'd like to be able to pipe coffeescript directly into coffeelint. Just like with coffeescript's --stdio.
This would make it easier to check code that is not saved to a file or only fragments of an existing file.

As an example: with TextMate I have to write the selection to a temporary file, pass it to coffeelint, and delete it.

TextMate command:

#!/bin/bash

cat ${TM_COFFEE} > /tmp/coffeelint
coffeelint /tmp/coffeelint
rm /tmp/coffeelint

Option to skip ANSI coloring

I'm invoking CoffeeLint in a script called from a Visual Studio build event. The problem is that the ANSI-colored output doesn't show in the Visual Studio output window.

It would be nice to have an option to skip ANSI coloring.

Exit after first file when errors

I would like to propose that a --bail argument to can be passed to coffeelint, and which when passed would ensure that an error would be thrown after the first parsed file containing any erroneous lints.

This way, coffeelint could be used to force consistency automatically when being invoked from a makefile and/or through continuous integration.

Here's how I would imagine it to work:

find src/js -name "*.coffee" -type f  -exec coffeelint -f coffeelint.json --bail  {} \;

  ✗ src/js/one.coffee
     ✗ #1: Line ends with trailing whitespace.

✗ Lint! » 1 error in 1 file

    // Throw error here and exit if --bail argument was passed. 

Option to ignore directories when recursing

There should be some way to ignore sub directories (specifically, node_modules) when using the -r flag, otherwise installed modules could cause the linter to print errors that aren't the concern of the user.

JSHint-like XML Report capabilities

Is this planned?

I'm trying to lint my coffee and get the output into something Jenkins can use thru the Violations plugin. I could always use JSHint with the proper configuration file used by Ashkenas but it would be nice for CoffeeLint to support this out of the box.

Option to ignore line length of comment lines

We document our code in comments using coffeedoc, and would prefer not to have to worry about hand-wrapping this documentation, since the browser will be the one to display these in their final form.

It would be nice to have an option to ignore line length of comment-only lines while still caring that code is not complex enough to reach X number of characters in length.

coffeelint: command not found

Hello, I am pretty new to bash and Terminal, so any help would be appreciated.

After installing CoffeeLint locally, I try to run it with:

$ coffeelint application.coffee

And I am met with:

-bash: coffeelint: command not found

I am assuming this in issue with my $PATH variable. When I enter:

$ echo $PATH

This is the $PATH given:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin

Any recommendations on how to correct this issue?

Thank you.

bump up npm release

would it be possible to do this?

would be particularly useful to get the command line stuff going:
SublimeLinter/SublimeLinter#118 will rely on this

not meaning to be pushy - if there's a particular reason not to release then don't do so prematurely

No output when spawn'd or exec'd on Windows

I'm having a strange problem on Windows when shelling out to CoffeeLint on Windows. Using the following code:

terminal = require("child_process").spawn("node", ["node_modules/coffeelint/bin/coffeelint", "-v"])

terminal.stdout.on "data", (data) ->
  console.log "stdout: " + data

terminal.stderr.on "data", (data) ->
  console.log "stderr: " + data

terminal.on "exit", (code) ->
  console.log "child process exited with code " + code

the output on windows is:

Z:\Code>coffee test.coffee
child process exited with code 0

Commenting out the process.exit() calls (https://github.com/clutchski/coffeelint/blob/master/src/commandline.coffee#L224) fixes it. It seems like the process is exiting before it has a chance to print because if I wrap the process.exit() with setTimeout(..., 100) it works fine.

space after function arrows

All function arrows should have either whitespace or newline characters following them.

-> a # good
->a # bad

"Implicit braces are forbidden" triggered with function call in class body

this valid coffeescript triggers the wrong error when calling a function in class body:

class A

  @configure(1, 2, 3)

  constructor: ->

pattern used all over the place by the spine framework

edit: that is, with the "no_implicit_braces" set to "error" of course, and which have nothing to do with the preceding example

Implicit braces - provide toggle for inline vs multi-line

I think the no_implicit_braces rule is good -- when we're dealing with one liners where there may be some confusion. I don't think that multi-line / indented object definitions are problematic. This is really similar to issue #21 - #21

I'm OK with this personally:

foo = 
  bar:
    baz: 1
    thing: 'a'
  baz: ['a', 'b', 'c']

But not OK with something like

foo = bar: { baz: 1, thing: 'a' }, baz: ['a', 'b', 'c']

I think it would be nice to allow a value to be specified in the options to change the behavior to only generate errors for inline vs mult-line definitions.

Thoughts?

anonymous classes

I was just rewriting the example on the website a little, when this code

# Lint your CoffeeScript!

Gangster = (class then wasItAGoodDay : -> yes)

turned up this error:

Your code has lint.
Line #3:Class names should be camel cased

recursive operation

Would love to be able to pass a directory and have all of its contents recursively lint-checked

Indentation Rule may be to constraining

One thing we tend to do is bring a method call which takes a function as a parameter to a new line. When we indent the body the function parameter things get weird.

OK:

somObject.method ()->
  object: 
    withValue: 'val'
    andValue: 'val'
// Generated by CoffeeScript 1.3.3

somObject.method(function() {
  return {
    object: {
      withValue: 'val',
      andValue: 'val'
    }
  };
});

NOT OK:

somObject
  .method ()->
    object: 
      withValue: 'val'
      andValue: 'val'
// Generated by CoffeeScript 1.3.3

somObject.method(function() {
  return {
    object: {
      withValue: 'val',
      andValue: 'val'
    }
  };
});

The "NOT OK" example complains about indentation at .method ()->

We would like to use this indentation style since its useful for chaining and some internal DSLs.

unnecessarily bound functions

Bound functions without any references to their context anywhere in their immediate scope (or their bound children's scope, recursively tested) should produce a warning.

=> this # good
=> "this" # bad
=> => => => this # good
=> -> => => this # bad

Inconsistent indentation on function body

Hello, trying to set the style for my mysql calls and coffeelinting the code I get an "inconsistent indentation" warning on the callback function body. Indenting in the same level as the arguments and function declaration removes the warning but I think it should not raise any warnings at it.

Is it the intended behavior?

mysql.query \
    """
    SELECT
        `user_id` as `id`,
        `user_name` as `name`,
        `user_password` as `password`
    FROM
        `users`
    WHERE
        `user_name` = ?
    LIMIT 1
    """,

    ['test'],

    (err,res) ->
        console.log err
        console.log res[0]

Also, thank you for the good work! :)

thisIsCamelCase

CamelCase is a generic name that can mean camelCase or CamelCase. When you want to specify initial caps explicitly, it's called PascalCase.

CoffeeLint Textmate Bundle

Any chance of a coffeelint textmate bundle in the near future?
It would be fantastic to be able to lint on save, and have a more detailed HTML window the same as the jslint bundle for textmate.

Recursive mode includes non-coffee files at first level

The issue shows up with a file structure like this:

./application.coffee
./application.sass
./random.js
./src/some_module.coffee
./styles/some_stylesheet.sass

Coffeelint will correctly not parse ./styles/some_stylesheet.sass, but it will attempt to parse ./application.sass and ./random.js. Right now I'm just using ack and xargs to make it work.

ack -g coffee$    | tr '\n' ' ' | xargs coffeelint

Thanks for an awesome tool. :)

How to pass in --jslint reporter when calling coffeelint through grunt?

I'm using grunt-coffeelint to run coffeelint over coffeescript code, and that works fine.

Now I need to make grunt generate output that can be sucked up by Jenkins. I see the --jslint command line option which is great.

However, the grunt task doesn't go through the CLI -- it just directly loads the linter, and passes it JSON for options.
https://github.com/vojtajina/grunt-coffeelint/blob/master/tasks/coffeelint.js#L11

Without digging into the CLI parsing code... is there an easy way to pass --jslint without using the command line?

Cannot install coffeelint on node 0.8.7 and npm 1.1.51

Minimatch, as far as I can see, is only available with a version number of 0.1.5. I'm confused as to why coffeelint is looking for > version 2.

matthewbeale:~ node -v
v0.8.7
matthewbeale:~ npm -v
1.1.51
matthewbeale:~ sudo npm install -f -g coffeelint
npm http GET https://registry.npmjs.org/coffeelint/-/coffeelint-0.4.0.tgz
npm http 200 https://registry.npmjs.org/coffeelint/-/coffeelint-0.4.0.tgz
npm http GET https://registry.npmjs.org/optimist/-/optimist-0.3.4.tgz
npm http GET https://registry.npmjs.org/coffee-script/-/coffee-script-1.2.0.tgz
npm http GET https://registry.npmjs.org/glob/-/glob-3.1.12.tgz
npm http 200 https://registry.npmjs.org/glob/-/glob-3.1.12.tgz
npm http 200 https://registry.npmjs.org/coffee-script/-/coffee-script-1.2.0.tgz
npm http 200 https://registry.npmjs.org/optimist/-/optimist-0.3.4.tgz
npm http GET https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.1.5.tgz
npm http GET https://registry.npmjs.org/inherits/-/inherits-1.0.0.tgz
npm ERR! Error: No compatible version found: minimatch@'>=0.2.0- <0.3.0-'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.4","0.0.5","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5"]
npm ERR!     at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:553:10)
npm ERR!     at next (/usr/local/lib/node_modules/npm/lib/cache.js:532:17)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:512:5
npm ERR!     at RegClient.get_ (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:101:14)
npm ERR!     at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:37:12)
npm ERR!     at fs.readFile (fs.js:176:14)
npm ERR!     at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:92:5)
npm ERR!     at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Darwin 10.8.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-f" "-g" "coffeelint"
npm ERR! cwd /Users/matthewbeale
npm ERR! node -v v0.8.7
npm ERR! npm -v 1.1.51
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/coffeelint/node_modules/coffee-script/lib/coffee-script/nodes.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Darwin 10.8.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-f" "-g" "coffeelint"
npm ERR! cwd /Users/matthewbeale
npm ERR! node -v v0.8.7
npm ERR! npm -v 1.1.51
npm ERR! path /usr/local/lib/node_modules/coffeelint/node_modules/coffee-script/lib/coffee-script/nodes.js
npm ERR! fstream_path /usr/local/lib/node_modules/coffeelint/node_modules/coffee-script/lib/coffee-script/nodes.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack Writer._finish.er.fstream_finish_call (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26)
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm http 200 https://registry.npmjs.org/inherits/-/inherits-1.0.0.tgz
npm http 200 https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.1.5.tgz
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/matthewbeale/npm-debug.log
npm ERR! not ok code 0

Ignore the sudo, I know it's bad but it should be unrelated. I forced to try and overcome the minimatch dependency.

Inappropriate apostrophe usage in "its" on homepage

http://www.coffeelint.org/:

CoffeeLint is in it's infancy

To enable an option, set it's level to error and to disable an option, set it's level to ignore.

The word "it's" means "it is" exclusively. The word in these two instances should be "its" (possessive).

(The remaining usage of the word "it's", in "it's critical", is correct.)

Yes, I care enough to even file bug reports for things like this.

trailing whitespace on empty lines does not trigger rule

having whitespace on an empty line does not trigger the trailing-whitespace rule, even though leading whitespace might exist due to autoindenters... might be nice to have a separate rule for this corner case?

    # blahblah
    # next line contains trailing whitespace (really, though markdown strips it!)

EOF

was expecting it to trigger "Line 3 contains trailing whitespace"

Parse error with UTF-8 BOM + @

I have a coffee file with a UTF-8 BOM marker that begins with a @:

<U+FEFF>@foo = bar

Coffeelint gives:

test.coffee(1): error: Error: Parse error on line 1: Unexpected '@'

If I start the file with an empty line, the error goes away.

Cyclomatic complexity is too high

There are two options for fixing this, we can raise the maximum cyclomatic complexity, or rewrite some of the more complex stuff (the new block disabling stuff mostly).

Since there seems to no easy way to rewrite it with less complexity I am opening up this issue for discussion.

Cannot run coffeelint on directories

I'm trying to run coffeelint on all files in a directory and eventually want to use -r to run it on my entire source tree.
I've tried the following (my coffeescript directory is 'coffee' inside the current directory):

coffeelint coffee
coffeelint coffee/
coffeelint coffee/*.coffee

The first two result in this exception:

var r = binding.read(fd, buffer, offset, length, position);
                  ^
Error: UNKNOWN, unknown error
    at Object.readSync (fs.js:283:19)
    at Object.readFileSync (fs.js:142:21)
    at C:\Users\chris\AppData\Roaming\npm\node_modules\coffeelint\bin\coffeelint
:33:15
    at C:\Users\chris\AppData\Roaming\npm\node_modules\coffeelint\bin\coffeelint
:289:16
    at Object.<anonymous> (C:\Users\chris\AppData\Roaming\npm\node_modules\coffe
elint\bin\coffeelint:346:21)
    at Object.<anonymous> (C:\Users\chris\AppData\Roaming\npm\node_modules\coffe
elint\bin\coffeelint:351:4)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)

The one with the * gives me this one:

  return binding.stat(pathModule._makeLong(path));
                 ^
Error: ENOENT, no such file or directory '<my-directory>\coffee\*.coffee'
    at Object.statSync (fs.js:424:18)
    at Object.realpathSync (fs.js:805:8)
    at C:\Users\chris\AppData\Roaming\npm\node_modules\coffeelint\bin\coffeelint
:32:19
    at C:\Users\chris\AppData\Roaming\npm\node_modules\coffeelint\bin\coffeelint
:289:16
    at Object.<anonymous> (C:\Users\chris\AppData\Roaming\npm\node_modules\coffe
elint\bin\coffeelint:346:21)
    at Object.<anonymous> (C:\Users\chris\AppData\Roaming\npm\node_modules\coffe
elint\bin\coffeelint:351:4)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)

This is on Windows 7 with the latest version from the Git master branch. Running coffeelint on an individual file works fine.
What am I doing wrong?

Warn about undefined variables

myfun = ->
  foo = bar

It should warn about the undefined bar variable. This something I miss the most from jshint/jslint.

indented arguments weirdness

I'm not sure this is a bug, it smells weird to me, thought I'd report

obj
  .method
    param: "val" # Line contains inconsistent indentation
obj.
  method
    param: "val" # Line contains inconsistent indentation
obj
  .method(
    param: "val" # Line contains inconsistent indentation
  )

obj
.method
  param: "val" # Line contains inconsistent indentation

obj.
method
  param: "val" # Line contains inconsistent indentation

obj
.method(
  param: "val" # Line contains inconsistent indentation
)

obj
  .method()
obj.
  method()
obj
.method()
obj.
method()

a = () ->
  obj # Line contains inconsistent indentation
  .method
    param: "val"
  obj
  .method
    param: "val"
a = () ->
  obj. # Line contains inconsistent indentation
  method
    param: "val"
  obj.
  method
    param: "val"
a = () ->
  obj # Line contains inconsistent indentation
  .method(
    param: "val"
  )
  obj
  .method(
    param: "val"
  )
a = () ->
  obj # Line contains inconsistent indentation
  .method(
    param: "val"
  )
  obj
  .method(
    param: "val"
  )

Newlines and classes

Maybe finishing touches of #44

Needs at least

  • documentation
  • entry in default configuration file
  • maybe change to newlines before classes, since code is most often read in that direction

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.