Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't compiled CoffeeScript pass JSHint? [closed]

I use the examples from the CoffeeScript homepage and it doesn't validate.

The for loop one is a perfect example, if you use the coffeescript statement it doesn't wrap the body in an if statement.

  • Expected '{' and instead saw 'child'.
  • Possible strict violation.
  • A constructor name should start with an uppercase letter.
  • 'insertclassnamehere' is already defined.
  • Did you mean to return a conditional instead of an assignment?
  • Expected '===' and instead saw '=='.
  • Unexpected '~'.
  • Expected '!==' and instead saw '!='.
  • The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
like image 893
Kirk Strobeck Avatar asked Feb 18 '23 23:02

Kirk Strobeck


1 Answers

My compiled CoffeeScript won't validate in JShint .. why?

The short answer would be: Because the creators of the CoffeeScript compiler didn't deem it necessary.

It makes sense to lint code which is written and maintained by developers. It avoids human errors by making code readable.

The code generated by a compiler on the other hand has completely different requirements. Readability is usually not a concern. It's more important that the code is efficient and small.

If you really want this then you need to modify the CoffeeScript compiler source.

like image 112
Christoph Leiter Avatar answered Mar 04 '23 06:03

Christoph Leiter