Socket
Socket
Sign inDemoInstall

eslint-plugin-jest

Package Overview
Dependencies
Maintainers
9
Versions
325
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jest - npm Package Compare versions

Comparing version 21.22.0 to 21.22.1

8

docs/rules/expect-expect.md

@@ -56,7 +56,7 @@ # Enforce assertion to be made in a test body (expect-expect)

test('returns sum', () => {
test('returns sum', () =>
expectSaga(addSaga, 1, 1)
.returns(2)
.run();
});
);
```

@@ -73,7 +73,7 @@

test('returns sum', () => {
test('returns sum', () =>
expectSaga(addSaga, 1, 1)
.returns(2)
.run();
});
);
```
{
"name": "eslint-plugin-jest",
"version": "21.22.0",
"version": "21.22.1",
"description": "Eslint rules for Jest",

@@ -49,5 +49,3 @@ "repository": "jest-community/eslint-plugin-jest",

"prettier": "^1.10.2",
"prettylint": "^1.0.0",
"semantic-release": "^15.0.2",
"travis-deploy-once": "^4.3.1"
"prettylint": "^1.0.0"
},

@@ -54,0 +52,0 @@ "prettier": {

@@ -6,3 +6,7 @@ 'use strict';

const ruleTester = new RuleTester();
const ruleTester = new RuleTester({
parserOptions: {
sourceType: 'module',
},
});

@@ -21,2 +25,31 @@ ruleTester.run('no-disabled-tests', rule, {

'(a || b).f()',
[
'import { pending } from "actions"',
'',
'test("foo", () => {',
' expect(pending()).toEqual({})',
'})',
].join('\n'),
[
'const { pending } = require("actions")',
'',
'test("foo", () => {',
' expect(pending()).toEqual({})',
'})',
].join('\n'),
[
'test("foo", () => {',
' const pending = getPending()',
' expect(pending()).toEqual({})',
'})',
].join('\n'),
[
'test("foo", () => {',
' expect(pending()).toEqual({})',
'})',
'',
'function pending() {',
' return {}',
'}',
].join('\n'),
],

@@ -23,0 +56,0 @@

@@ -22,2 +22,29 @@ 'use strict';

function collectReferences(scope) {
const locals = new Set();
const unresolved = new Set();
let currentScope = scope;
while (currentScope !== null) {
for (const ref of currentScope.variables) {
const isReferenceDefined = ref.defs.some(def => {
return def.type !== 'ImplicitGlobalVariable';
});
if (isReferenceDefined) {
locals.add(ref.name);
}
}
for (const ref of currentScope.through) {
unresolved.add(ref.identifier.name);
}
currentScope = currentScope.upper;
}
return { locals, unresolved };
}
module.exports = {

@@ -62,3 +89,15 @@ meta: {

case 'pending':
case 'pending': {
const references = collectReferences(context.getScope());
if (
// `pending` was found as a local variable or function declaration.
references.locals.has('pending') ||
// `pending` was not found as an unresolved reference,
// meaning it is likely not an implicit global reference.
!references.unresolved.has('pending')
) {
break;
}
if (testDepth > 0) {

@@ -81,2 +120,3 @@ context.report({

break;
}

@@ -83,0 +123,0 @@ case 'xdescribe':

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc