Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules): prefer-hooks-on-top #425

Merged
merged 3 commits into from Oct 12, 2019

Conversation

Mark1626
Copy link
Contributor

Fixes #356

Approach is to maintain a stack of boolean which gets marked as true when a hook is not before a test

Also an edge case

describe("foo" () => {
  beforeEach(() => {
    //some hook code
  });
  
  // Not affected by rule
  someSetup();

  afterEach(() => {
    //some hook code
  });
  test("bar" () => {
    some_fn();
  });
});

@Mark1626
Copy link
Contributor Author

Mark1626 commented Oct 1, 2019

CI is a lint issue, I'll push a commit along with the review changes

@Mark1626
Copy link
Contributor Author

Mark1626 commented Oct 1, 2019

@G-Rath Changed it to string templates

@G-Rath G-Rath added the new rule label Oct 5, 2019
@G-Rath G-Rath self-requested a review October 12, 2019 01:30
Copy link
Collaborator

@G-Rath G-Rath left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Cheers for all those changes :)

@G-Rath G-Rath merged commit ad3fc06 into jest-community:master Oct 12, 2019
@SimenB
Copy link
Member

SimenB commented Oct 12, 2019

🎉 This PR is included in version 22.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

New rule suggestion: Place all hooks at the top of the block.
3 participants