eslint-plugin-jest icon indicating copy to clipboard operation
eslint-plugin-jest copied to clipboard

Create `prefer-to-*` rules for `jest-extended`

Open SimenB opened this issue 7 years ago • 10 comments

There are a bunch of specific rules in https://github.com/jest-community/jest-extended which can be preferred.

I suggest we have rules suggesting their use. So e.g toBeFalse() over toBe(false) etc.

Should be clear in the docs that they are only if you use jest-extended.

/cc @mattphillips

SimenB avatar Nov 24 '17 15:11 SimenB

Hey @SimenB interestingly I started a new project to do this a week or so ago but haven’t had time to work on it. Check it out here: https://www.github.com/mattphillips/eslint-plugin-jest-extended I was planning on moving it to jest-community once id published it. I’m happy for it to live as part of this plugin though :)

mattphillips avatar Nov 25 '17 09:11 mattphillips

IMO it's fine to have it as one plugin, as long as it's clearly stated in the docs that the matchers are not part of Jest core.

/cc @thymikee @orta @jkimbo @rogeliog thoughts?

SimenB avatar Nov 25 '17 09:11 SimenB

Hm, I don't know, with separate plugin we can just do:

plugins: ['jest', 'jest-extended']

and have rules easily distinguishable.

thymikee avatar Nov 25 '17 10:11 thymikee

I was thinking of sharing some utils such as

const parsedExpression = utils.parse(node);

if (parsedExpression.isExpect) {
  if (parsedExpression.matcher === 'toBeNull') {}
}

And a bunch of other stuff. I suppose we can publish that as a separate thing though - seems useful for the jasmine plugin as well.

SimenB avatar Nov 25 '17 10:11 SimenB

Or move both plugins to new monorepo eslint-jest?

thymikee avatar Nov 25 '17 10:11 thymikee

Uuuh, yeah that might be the way forward

SimenB avatar Nov 25 '17 10:11 SimenB

But that's just a lot of work with lerna setup probably 😄

thymikee avatar Nov 25 '17 10:11 thymikee

Lerna setup isn't too bad. I also noticed that lerna has built-in conventional commit support now, so we could probably automate a bunch of stuff around it (and maybe bring those learnings back into jest core)

SimenB avatar Nov 25 '17 10:11 SimenB

That would be amazing

thymikee avatar Nov 25 '17 10:11 thymikee

Follow-up: https://github.com/jest-community/eslint-plugin-jest-extended/issues/2

ge65cer avatar Jun 28 '22 13:06 ge65cer

I'm going to resolve this since we've now got eslint-plugin-jest-extended published 🎉

G-Rath avatar Aug 27 '22 20:08 G-Rath