eslint-plugin-jest 28.8.3 → 28.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +34 -28
  2. package/index.d.ts +28 -0
  3. package/package.json +6 -4
package/README.md CHANGED
@@ -22,28 +22,43 @@ yarn add --dev eslint eslint-plugin-jest
22
22
 
23
23
  ## Usage
24
24
 
25
- > [!NOTE]
26
- >
27
- > `eslint.config.js` is supported, though most of the plugin documentation still
28
- > currently uses `.eslintrc` syntax.
29
- >
30
- > Refer to the
31
- > [ESLint documentation on the new configuration file format](https://eslint.org/docs/latest/use/configure/configuration-files-new)
32
- > for more.
25
+ If you're using flat configuration:
33
26
 
34
- Add `jest` to the plugins section of your `.eslintrc` configuration file. You
35
- can omit the `eslint-plugin-` prefix:
27
+ With
28
+ [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files),
29
+ just import the plugin and away you go:
36
30
 
37
- ```json
38
- {
39
- "plugins": ["jest"]
40
- }
31
+ ```js
32
+ const pluginJest = require('eslint-plugin-jest');
33
+
34
+ module.exports = [
35
+ {
36
+ // update this to match your test files
37
+ files: ['**/*.spec.js', '**/*.test.js'],
38
+ plugins: { jest: pluginJest },
39
+ languageOptions: {
40
+ globals: pluginJest.environments.globals.globals,
41
+ },
42
+ rules: {
43
+ 'jest/no-disabled-tests': 'warn',
44
+ 'jest/no-focused-tests': 'error',
45
+ 'jest/no-identical-title': 'error',
46
+ 'jest/prefer-to-have-length': 'warn',
47
+ 'jest/valid-expect': 'error',
48
+ },
49
+ },
50
+ ];
41
51
  ```
42
52
 
43
- Then configure the rules you want to use under the rules section.
53
+ With legacy configuration, add `jest` to the plugins section of your `.eslintrc`
54
+ configuration file. You can omit the `eslint-plugin-` prefix:
44
55
 
45
56
  ```json
46
57
  {
58
+ "plugins": ["jest"],
59
+ "env": {
60
+ "jest/globals": true
61
+ },
47
62
  "rules": {
48
63
  "jest/no-disabled-tests": "warn",
49
64
  "jest/no-focused-tests": "error",
@@ -54,19 +69,10 @@ Then configure the rules you want to use under the rules section.
54
69
  }
55
70
  ```
56
71
 
57
- You can also tell ESLint about the environment variables provided by Jest by
58
- doing:
59
-
60
- ```json
61
- {
62
- "env": {
63
- "jest/globals": true
64
- }
65
- }
66
- ```
67
-
68
- This is included in all configs shared by this plugin, so can be omitted if
69
- extending them.
72
+ > [!NOTE]
73
+ >
74
+ > You only need to explicitly include our globals if you're not using one of our
75
+ > shared configs
70
76
 
71
77
  #### Aliased Jest globals
72
78
 
package/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import type { Linter, Rule } from 'eslint';
2
+
3
+ declare const plugin: {
4
+ meta: {
5
+ name: string;
6
+ version: string;
7
+ };
8
+ environments: {
9
+ globals: {
10
+ globals: {
11
+ [key: string]: boolean;
12
+ };
13
+ };
14
+ };
15
+ configs: {
16
+ all: Linter.LegacyConfig;
17
+ recommended: Linter.LegacyConfig;
18
+ style: Linter.LegacyConfig;
19
+ 'flat/all': Linter.FlatConfig;
20
+ 'flat/recommended': Linter.FlatConfig;
21
+ 'flat/style': Linter.FlatConfig;
22
+ };
23
+ rules: {
24
+ [key: string]: Rule.RuleModule;
25
+ };
26
+ };
27
+
28
+ export = plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "28.8.3",
3
+ "version": "28.9.0",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -15,9 +15,11 @@
15
15
  "url": "jkimbo.com"
16
16
  },
17
17
  "main": "lib/index.js",
18
+ "types": "index.d.ts",
18
19
  "files": [
19
20
  "docs/",
20
- "lib/"
21
+ "lib/",
22
+ "index.d.ts"
21
23
  ],
22
24
  "scripts": {
23
25
  "build": "babel --extensions .js,.ts src --out-dir lib --copy-files && rimraf --glob lib/__tests__ 'lib/**/__tests__'",
@@ -74,7 +76,7 @@
74
76
  "@tsconfig/node16": "^16.0.0",
75
77
  "@types/eslint": "^8.4.6",
76
78
  "@types/jest": "^29.0.0",
77
- "@types/node": "^14.18.26",
79
+ "@types/node": "^16.0.0",
78
80
  "@typescript-eslint/eslint-plugin": "^6.0.0",
79
81
  "@typescript-eslint/parser": "^6.0.0",
80
82
  "@typescript-eslint/utils": "^6.0.0",
@@ -118,7 +120,7 @@
118
120
  "optional": true
119
121
  }
120
122
  },
121
- "packageManager": "yarn@3.8.4",
123
+ "packageManager": "yarn@3.8.6",
122
124
  "engines": {
123
125
  "node": "^16.10.0 || ^18.12.0 || >=20.0.0"
124
126
  },