dangreenisrael / eslint-plugin-jest-formatting

ESLint rules for formatting test suites written for jest.
MIT License
156 stars 13 forks source link

[Rule] Disable padding around todo test blocks #86

Closed aymericbouzy closed 3 years ago

aymericbouzy commented 4 years ago

There should not be padding around todo test blocks.

Valid code example

describe("valid", () => {
  it.todo("foo")
  it.todo("bar")
  it.todo("baz")
})

Invalid code example

describe("invalid", () => {
  it.todo("foo")

  it.todo("bar")

  it.todo("baz")
})

Maybe this can be an option to padding-around-test-blocks ?

benkimpel commented 4 years ago

@aymericbouzy Interesting rule request! I hadn't considered that before.

My quick reaction is that one might more often want their it.todo padding to match their it padding since then they could just remove the .todo, implement the test, and have valid padding at that point, but I do recognize that one form is typically multiline while the other is not and I can appreciate the aesthetic difference.

Could be an interesting rule to implement since, iirc, we don't look past the first token right now.

Disclaimer I'm just a contributor. :)

@dangreenisrael @hockeybuggy thoughts?

dangreenisrael commented 4 years ago

I think having it as an option would be nice, but I won't have any time for it for at least the next 2 months.

@hockeybuggy Thoughts?

hockeybuggy commented 4 years ago

Based on @benkimpel's thoughts related to the padding being unchanged after dropping the .todos it seems like this would be good thing to have be opt in (this would also avoid a breaking change [if we considering rules failing to be breaking]).

Seems like it.todo would be the only method that this would really make sense for (.each, .only, .skip don't seem to make sense to have padding variations).

I think my stance is that if someone would like to contribute this, I would be in favour of including it.

aymericbouzy commented 4 years ago

As I've said in #85 I've never written an ESlint rule before, but I'm willing to try 👍

dangreenisrael commented 4 years ago

@aymericbouzy No time like the present to learn something new. I learned with this course. https://frontendmasters.com/courses/linting-asts/

dangreenisrael commented 3 years ago

Hey, I'm closing this due to a seeming lack of interest. If it can get 5 +1s I'll reopen it.