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

docs: expand on how jest version is determined and common workarounds #897

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,43 @@ doing:
This is included in all configs shared by this plugin, so can be omitted if
extending them.

The behaviour of some rules (specifically `no-deprecated-functions`) change
depending on the version of `jest` being used.
### Jest `version` setting

This setting is detected automatically based off the version of the `jest`
package installed in `node_modules`, but it can also be provided explicitly if
desired:
The behaviour of some rules (specifically [`no-deprecated-functions`][]) change
depending on the version of Jest being used.

By default, this plugin will attempt to determine the version of Jest
automatically by looking for Jest in the `node_modules` of _the working directly
that ESLint is being run from_.

If you're working with a project structure that means Jest is not installed at
the same directory level as where you run ESLint (such as if you're using a
mono-repo structure but not hoisting dependencies to the root of the repo) you
will need to provide the Jest version explicitly:

```json
{
"settings": {
"jest": {
"version": 26
"version": 27
}
}
}
```

To avoid hard-coding a number, you can also fetch it from the installed version
of Jest if you use a JavaScript config file such as `.eslintrc.js`:

```js
module.exports = {
settings: {
jest: {
version: require('jest/package.json').version,
},
},
};
```

## Shareable configurations

### Recommended
Expand Down Expand Up @@ -226,3 +246,4 @@ https://github.com/istanbuljs/eslint-plugin-istanbul
[suggest]: https://img.shields.io/badge/-suggest-yellow.svg
[fixable]: https://img.shields.io/badge/-fixable-green.svg
[style]: https://img.shields.io/badge/-style-blue.svg
[`no-deprecated-functions`]: docs/rules/no-deprecated-functions.md
4 changes: 4 additions & 0 deletions docs/rules/no-deprecated-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ either been renamed for clarity, or replaced with more powerful APIs.
While typically these deprecated functions are kept in the codebase for a number
of majors, eventually they are removed completely.

This rule requires knowing which version of Jest you're using - see
[this section of the readme](README.md) for details on how that is obtained
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link doesn't work, does it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't - IntelliJ seems to have weird handling of relative links in nested docs :/

automatically and how you can explicitly provide a version if needed.

## Rule details

This rule warns about calls to deprecated functions, and provides details on
Expand Down