Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Fixed decorated methods declared after usage (#813) #852

Merged
merged 1 commit into from
Mar 31, 2019

Conversation

soon
Copy link
Contributor

@soon soon commented Mar 28, 2019

PR checklist

Overview of change:

This MR fixes a bug with react-this-binding-issue rule when the decorated method was declared after usage.

@msftclas
Copy link

msftclas commented Mar 28, 2019

CLA assistant check
All CLA requirements met.

@IllusionMH IllusionMH added the PR: Waiting for Reviewer A repository maintainer should take a look at the pull request soon! label Mar 29, 2019
Copy link

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, LGTM. Thanks so much @soon!

@JoshuaKGoldberg JoshuaKGoldberg merged commit e92a08f into microsoft:master Mar 31, 2019
@cyberhck
Copy link
Contributor

cyberhck commented Apr 1, 2019

thanks a lot :) I couldn't come around to do this, but this will definitely help with all my projects + a few others I know :)

@cyberhck
Copy link
Contributor

cyberhck commented Apr 9, 2019

any idea when's the new release?

@JoshuaKGoldberg
Copy link

@cyberhck good idea! I'll aim for releasing one this weekend.

@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.1.1-beta milestone Apr 15, 2019
@cyberhck
Copy link
Contributor

is it working now? For some reason I still don't seem to be correct, I'm using 6.1.1

image

@soon
Copy link
Contributor Author

soon commented May 12, 2019

@cyberhck Could you please provide the code which causes the issue?

@cyberhck
Copy link
Contributor

export class HomePage extends React.Component {
  public render(): JSX.Element {
    return (
      <div className={classNames.container}>
        <h2>Register</h2>
        <button onClick={this.handleClick}>Click to register</button>
      </div>
    );
  }

  @autobind
  private async handleClick(): Promise<void> {
    const sdk = Api.getInstance();
    const response = await sdk.users.create({email: "[email protected]", password: "secret", username: "user"});
    console.info("registered new user: ", response);
  }
}

And my tslint has this:

    "react-this-binding-issue": [true, {"bind-decorators": ["autobind"]}],

@soon
Copy link
Contributor Author

soon commented May 12, 2019

@cyberhck It seems like 6.1.1 does not include these changes. Quick check - download https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-6.1.1.tgz (or find it in node_modules) and open reactThisBindingIssueRule.js file. It does not have visitClassMember function and node.members.forEach(visitClassMember); call added in tihs PR.

/cc @JoshuaKGoldberg

@cyberhck
Copy link
Contributor

ahh, okay, next release then :) thanks.

@IllusionMH
Copy link
Contributor

Thank you @cyberhck for noticing and @soon for investigation.
There are few PRs that I would like to fit into next release (that will include this fix), however I will release new beta version this weekend even without PRs merged.

@cyberhck
Copy link
Contributor

@IllusionMH hey have you considered using semantic-release for releasing? 🙂 I was wondering if that'd fit this project :)

@IllusionMH
Copy link
Contributor

IllusionMH commented May 15, 2019

@cyberhck we've discussed some improvements to release process (and using tools like semantic-release), however no concrete steps yet. Current release workflow is a bit cumbersome and will require effort to migrate (given my limited access to configurations and experience with mentioned tools).

We think of possible improvements to the process again and hopefully come up with more concrete plan. Feel free to create new issue if you have proposals or info to share - would be glad to discuss them.

UPD. I don't think that it will be fully automatic (on CI) as semantic-release supports, but still would make it easier to up version, compose release notes, update docs and publish package and will reduce likelihood of similar issues.

@cyberhck cyberhck mentioned this pull request May 16, 2019
@IllusionMH IllusionMH modified the milestones: 6.1.1-beta, 6.2.0-beta May 18, 2019
@IllusionMH
Copy link
Contributor

6.2.0-beta was published to npm so you can try it with npm i tslint-microsoft-contrib@beta. 6.2.0 on Wednesday if no blockers.

And sorry for the inconvenience.

P.S. More details on proposal for automation next week

@cyberhck
Copy link
Contributor

And sorry for the inconvenience.

No worries, that's not much of inconvenience actually, being in FOSS world, PR is already merged, so sooner or later we're gonna get it, all we can do is improve the workflow.

P.S. More details on proposal for automation next week

I'm not sure if you saw, but I did create a new issue for this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR: Waiting for Reviewer A repository maintainer should take a look at the pull request soon!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

react-bind-this-issue doesn't detect bind decorators defined after usage
5 participants