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

Rule proposal: spaces between test blocks #145

Closed
tswaters opened this issue Nov 5, 2017 · 4 comments
Closed

Rule proposal: spaces between test blocks #145

tswaters opened this issue Nov 5, 2017 · 4 comments
Labels

Comments

@tswaters
Copy link

tswaters commented Nov 5, 2017

I tried to get some combination of existing rules from eslint to describe this style, but couldn't quite do it without adversely affecting the code inside the test block.

I propose a rule that affects expression statements with a name of one of the mocha test functions (describe, it, before/after/etc) and enforces spacing before and after the test with options for always or never.

Example of bad code with option 'always':

describe('some describe', () => {
  it('should really have spacing', () => {})
})

Example of bad code with option 'never':

describe('some describe', () => {

  it('shouldnt have spacing', () => {})

})

I have this written and was just going to include it in a custom plugin - but then I saw this project existed so I figured I'd share it.

tswaters added a commit to tswaters/eslint-plugin-mocha that referenced this issue Nov 5, 2017
@lo1tuma lo1tuma added the feature label Nov 5, 2017
@lo1tuma
Copy link
Owner

lo1tuma commented Nov 5, 2017

Sounds like a good addition for this plugin 👍 .

@rugk
Copy link

rugk commented Aug 8, 2018

Oh, rather thought about requiring spaces between each test case:

describe('some describe', () => {
  it('should really have spacing after this', () => {})
})

describe('some describe', () => {
  it('it had an empty line, good', () => {})
})

@bjornua
Copy link
Contributor

bjornua commented Jan 24, 2024

@lo1tuma we could consider closing this one as #340 seems to mostly address this.

@lo1tuma
Copy link
Owner

lo1tuma commented Feb 16, 2024

Agreed. Although the current rule only supports spacing between. But as I said if there is a demand for other options someone should file a dedicated feature request.

@lo1tuma lo1tuma closed this as completed Feb 16, 2024
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.

4 participants