eslint-plugin-jest
Advanced tools
Comparing version 21.22.0 to 21.22.1
@@ -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': |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153305
13
4344