Space After Dot
Closed this issue · 2 comments
CoffeeScript allows this:
a. x
#or
a.
x
but it's almost certainly bad style when you can do things like this:
[1,2,3].
filter((x) -> x % 2 is 0).
map((x) -> x**2)
# or even worse
[1,2,3].
forEach (x) -> # Not obviously a method call of the previous list just from seeing the function
console.log(x)
over this:
[1,2,3]
.filter((x) -> x % 2 is 0)
.map((x) -> x**2)
[1,2,3]
.forEach (x) -> # Easy to tell it belongs to something previous because of the dot
console.log(x)
My proposed addition to add a rule to prevent spaces after a property access (spaces before the property access are unchanged)
You're welcome to build and publish a 3rd party rule for this. I don't use CoffeeScript any more, so this is unlikely to get implemented here. If you do implement it make sure to leave a comment here and take a look at https://github.com/clutchski/coffeelint/blob/master/3rd_party_rules.md
I highly recommend replacing CoffeeScript with Babel and CoffeeLint with ESLint. They are better tools that are better supported, and CoffeeScript doesn't appear to have a future as far as I can tell.
this is probably not implementable without hacking it like the indent rule. coffeescript just slurps up the first method in a chained call to the same line as the object callee(?)