No explanation for jest/no-restricted-matchers
See original GitHub issueI can’t find any rationale for why these particular matchers are restricted.
d3a48e6a3fade2c8dba6b3adda395fec39365986
The jest/no-restricted-matchers rule can be configured to suggest an alternative to the restricted method. Please add some sort of explanation, even if there’s no alternative.
{
"jest/no-restricted-matchers": [
"error",
{
"toMatchSnapshot": "Write a more targeted assertion instead of a snapshot",
"toMatchInlineSnapshot": "Write a more targeted assertion instead of a snapshot",
"toThrowErrorMatchingSnapshot": "Write a more targeted assertion instead of a snapshot",
"toThrowErrorMatchingInlineSnapshot": "Write a more targeted assertion instead of a snapshot",
"toBeTruthy": "use expect(x == true).toBeTrue() instead",
"toBeFalsy": "use expect(x == false).toBeTrue() instead",
"toBeDefined": "use .not.toBe(undefined)"
}
]
}
Or, preferably, remove these rules. Especially the toBeTruthy
, toBeFalsy
, and toBeDefined
ones. IMHO the alternatives are much more error prone.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
eslint-plugin-jest/no-restricted-matchers.md at main - GitHub
This rule bans specific matchers & modifiers from being used, and can suggest alternatives. Options. Bans are expressed in the form of a...
Read more >node_modules/eslint-plugin-jest/docs/rules/no-restricted-matchers ...
Disallow specific matchers & modifiers ( no-restricted-matchers ) ... This rule bans specific matchers & modifiers from being used, and can suggest alternatives....
Read more >Untitled
Jest `version` setting The behaviour of some rules (specifically [`no-deprecated-functions`][]) change depending on the version of Jest being used.
Read more >eslint-plugin-jest - npm
Start using eslint-plugin-jest in your project by running `npm i eslint-plugin-jest`. ... no-restricted-matchers, Disallow specific matchers & modifiers.
Read more >eslint-plugin-jest | Yarn - Package Manager
no -mocks-import, Disallow manually importing from __mocks__, ✓ ; no-restricted-jest-methods, Disallow specific jest. methods ; no-restricted-matchers, Disallow ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, I’ll add some explanations and leave it at that.
I agree with you about snapshot testing. Didn’t even know the rule existed until I looked at the config. 😃
Released in v24.4.0.