Skip to content

Commit

Permalink
docs: expand on how jest version is determined and common workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Sep 17, 2021
1 parent 34b23e6 commit 5b7c039
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,40 @@ 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.
depending on the version of Jest being used.

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:
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

0 comments on commit 5b7c039

Please sign in to comment.