synesthesia-project/synesthesia

Replace binds with arrow functions

s0 opened this issue · 15 comments

s0 commented

There's probably an eslint rule that requires arrow functions on clatt methods, and maybe for all functions. If we could find that and enable that, then that would help us find and hunt down all the places where we need to fix it too, it may also be auto-fixable.

We should open separate PRs for different projects / parts of the repos so that we reduce the likelihood of conflicts.

(Unless only one person is working on it)

would you assign this issue to me?

s0 commented

Sure!

can you give an example of it so I understand it better what changes you want

private onTimelineSelectorMouseOut() {
    this.setState({ selector: { state: 'nothing' } });
  }
  
  this.onTimelineSelectorMouseOut =
      this.onTimelineSelectorMouseOut.bind(this);
  **to this code**
      private onTimelineSelectorMouseOut=()=> {
    this.setState({ selector: { state: 'nothing' } });
  }
  
  this.onTimelineSelectorMouseOut =(...event)=>{
      this.onTimelineSelectorMouseOut.apply(this,event);
    }
s0 commented

can you give an example of it so I understand it better what changes you want

This plugin has good examples of what I mean, and enabling it may help to find all instances that need to be changed: https://www.npmjs.com/package/eslint-plugin-prefer-arrow-functions

s0 commented
private onTimelineSelectorMouseOut() {
    this.setState({ selector: { state: 'nothing' } });
  }
  
  this.onTimelineSelectorMouseOut =
      this.onTimelineSelectorMouseOut.bind(this);
  **to this code**
      private onTimelineSelectorMouseOut=()=> {
    this.setState({ selector: { state: 'nothing' } });
  }
  
  this.onTimelineSelectorMouseOut =(...event)=>{
      this.onTimelineSelectorMouseOut.apply(this,event);
    }

Almost, the first bit is changed correctly, but the second but is not needed at all any more!

so I remove all bind from constructor after making arrow functions?

s0 commented

so I remove all bind from constructor after making arrow functions?

Correct!

I changed some binds with the arrow function please ensure.
Is it correct then I start changing all binds too

please let me know what format are you looking for.
according to me, I did the necessary changes to replace the bind with the arrow function
is there any other way I can work on it?

I did the rush lint:fix in composer file it changes all files and i doesn't see any changes

I done sir

error: failed to push some refs to 'https://github.com/MohitBansal321/synesthesia.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I am getting error of this after commit of new file

I think I almost resolve the issue
it is excellent to work with you @s0
Thank You