eslint-plugin-jest 28.1.0 → 28.2.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.
package/README.md CHANGED
@@ -87,6 +87,27 @@ You can tell this plugin about any global Jests you have aliased using the
87
87
  }
88
88
  ```
89
89
 
90
+ #### Aliased `@jest/globals`
91
+
92
+ You can tell this plugin to treat a different package as the source of Jest
93
+ globals using the `globalPackage` setting:
94
+
95
+ ```json
96
+ {
97
+ "settings": {
98
+ "jest": {
99
+ "globalPackage": "bun:test"
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ > [!WARNING]
106
+ >
107
+ > While this can be used to apply rules when using alternative testing libraries
108
+ > and frameworks like `bun`, `vitest` and `node`, there's no guarantee the
109
+ > semantics this plugin assumes will hold outside of Jest
110
+
90
111
  ### Running rules only on test-related files
91
112
 
92
113
  The rules provided by this plugin assume that the files they are checking are
@@ -47,6 +47,9 @@ var _default = exports.default = (0, _utils2.createRule)({
47
47
  'ArrowFunctionExpression:exit': maybeResetCount,
48
48
  CallExpression(node) {
49
49
  const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
50
+ if (jestFnCall?.type === 'test') {
51
+ count = 0;
52
+ }
50
53
  if (jestFnCall?.type !== 'expect' || jestFnCall.head.node.parent?.type === _utils.AST_NODE_TYPES.MemberExpression) {
51
54
  return;
52
55
  }
@@ -309,9 +309,10 @@ const resolveToJestFn = (context, accessor) => {
309
309
  return null;
310
310
  }
311
311
  if (maybeImport) {
312
- // the identifier is imported from @jest/globals,
313
- // so return the original import name
314
- if (maybeImport.source === '@jest/globals') {
312
+ const globalPackage = context.settings.jest?.globalPackage ?? '@jest/globals';
313
+
314
+ // the identifier is imported from our global package so return the original import name
315
+ if (maybeImport.source === globalPackage) {
315
316
  return {
316
317
  original: maybeImport.imported,
317
318
  local: maybeImport.local,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "28.1.0",
3
+ "version": "28.2.0",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",