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

[new rule] prefer blank line between tests or blocks #1251

Closed
HaveSpacesuit opened this issue Sep 26, 2022 · 3 comments · Fixed by #1563
Closed

[new rule] prefer blank line between tests or blocks #1251

HaveSpacesuit opened this issue Sep 26, 2022 · 3 comments · Fixed by #1563
Labels

Comments

@HaveSpacesuit
Copy link

Add a style rule to suggest adding a blank line between tests or blocks.

// INCORRECT
beforeAll(() => {
  /* ... */
}) // missing space after
describe('function a', () => {
  beforeEach(() => {
    /* ... */
  }) // missing space after
  it('returns one', () => {
    /* ... */
  }) // missing space after
  it('returns two', () => {
    /* ... */
  })
}) // missing space after
describe('function b', () => {
  it('returns three', () => {
    /* ... */
  }) // missing space after
  it('returns four', () => {
    /* ... */
  })
})

// CORRECT
beforeAll(() => {
  /* ... */
}) // space after

describe('function c', () => {
  beforeEach(() => {
    /* ... */
  }) // space after

  it('returns five', () => {
    /* ... */
  }) // space after

  it('returns six', () => {
    /* ... */
  })
}) // space after

describe('function d', () => {
  it('returns seven', () => {
    /* ... */
  }) // space after

  it('returns eight', () => {
    /* ... */
  })
})

I suppose the opposite could be enforced - for people who don't want spaces between blocks. Optionally, could add rules for only tests, only describe/before/after blocks, etc.

@G-Rath
Copy link
Collaborator

G-Rath commented Sep 26, 2022

Is this not covered by eslint-plugin-jest-formatting?

@HaveSpacesuit
Copy link
Author

Thanks for the pointer! I didn't know about that package. Every time a new developer joins my team, I go searching for more lint rules! 🤣🤣🤣

Copy link

github-actions bot commented Aug 7, 2024

🎉 This issue has been resolved in version 28.8.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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants