Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Added prefer_fat_arrows_in_methods rule #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mitar
Copy link
Contributor

@mitar mitar commented May 19, 2015

Tests don't pass because I have no idea how to detect assigning to the prototype.

@mitar
Copy link
Contributor Author

mitar commented May 26, 2015

Any suggestions here?

@za-creature
Copy link
Contributor

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:

  1. What about requiring:

    class Foo
      bar: =>
        console.log("I'm exclusively foo")
    
  2. 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

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

@mitar
Copy link
Contributor Author

mitar commented Mar 6, 2016

I would also love to help with coffeelint.

@UziTech
Copy link

UziTech commented Jan 14, 2020

@mitar if you still want to help with coffeelint I have moved the repo to https://github.com/coffeelint/coffeelint

@UziTech
Copy link

UziTech commented Jan 14, 2020

Further development on coffeelint will be on coffeelint/coffeelint and will be released as @coffeelint/cli.

This PR will be tracked at coffeelint/coffeelint#15

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants