coffeelint
coffeelint copied to clipboard
Added prefer_fat_arrows_in_methods rule
Tests don't pass because I have no idea how to detect assigning to the prototype.
Any suggestions here?
Not 100%, but the AST should look very similar to this:
Assign(
variable: Value(
base: Literal("className"),
properties: [
Access(
name=Literal("prototype")
),
Access(
name=Literal("methodName")
)
]
),
value: Code(...)
)
Sometimes the Literals are replaced by plain strings so you should probably check for that as well.
So basically, find code that assigns a method to something.prototype.something and scan that method's code using your existing implementation.
Some food for thought:
-
What about requiring:
class Foo bar: => console.log("I'm exclusively foo")
-
How does this interact with no_unnecessary_fat_arrows ? I think you'll also need to check if
this
is used inside the function body and don't enforce any constraints if it isn't -
What happens here:
class Foo bar: -> class Baz constructor: -> # can't ever have a bound constructor so will this fail?
If you need help, I'm happy to take this over. However I'd like to resurrect the community behind coffeelint as the project needs a lot of love.
I would also love to help with coffeelint.
@mitar if you still want to help with coffeelint I have moved the repo to https://github.com/coffeelint/coffeelint
Further development on coffeelint will be on coffeelint/coffeelint and will be released as @coffeelint/cli.
This PR will be tracked at https://github.com/coffeelint/coffeelint/pull/15