From 8d1ca5ec8a2232a711a06961534cf7fa1f784950 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 17 Sep 2021 14:31:06 +1200 Subject: [PATCH 1/3] docs: expand on how jest version is determined and common workarounds --- README.md | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aea3318fe..be8964744 100644 --- a/README.md +++ b/README.md @@ -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 From ac1a6008ea1c5c35b8843900f12697ecfd0b1a46 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 23 Sep 2021 07:12:59 +1200 Subject: [PATCH 2/3] docs: link to `no-deprecated-functions` from readme --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be8964744..f2e93e09f 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,9 @@ 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 +### Jest `version` setting + +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 @@ -244,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 From 0626bbb03b4e386b343b4d561e5714aa7937f86a Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 23 Sep 2021 07:18:03 +1200 Subject: [PATCH 3/3] docs(no-deprecated-function): link to readme section about jest version --- docs/rules/no-deprecated-functions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/rules/no-deprecated-functions.md b/docs/rules/no-deprecated-functions.md index c591e0aeb..bf12894a8 100644 --- a/docs/rules/no-deprecated-functions.md +++ b/docs/rules/no-deprecated-functions.md @@ -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 +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