Socket
Socket
Sign inDemoInstall

eslint-plugin-jest

Package Overview
Dependencies
Maintainers
11
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 22.7.2 to 22.8.0

docs/rules/no-duplicate-hooks.md

2

lib/__tests__/rules.test.js

@@ -11,3 +11,3 @@ 'use strict';

const ruleNames = Object.keys(rules);
const numberOfRules = 32;
const numberOfRules = 33;
describe('rules', () => {

@@ -14,0 +14,0 @@ it('should have a corresponding doc for each rule', () => {

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

const testFunctions = Object.assign(Object.create(null), {
describe: true,
it: true,
test: true
});
const testFunctions = new Set(['describe', 'it', 'test']);
const matchesTestFunction = object => object && testFunctions[object.name];
const matchesTestFunction = object => object && testFunctions.has(object.name);
const isCallToFocusedTestFunction = object => object && object.name[0] === 'f' && testFunctions[object.name.substring(1)];
const isCallToFocusedTestFunction = object => object && object.name[0] === 'f' && testFunctions.has(object.name.substring(1));

@@ -17,0 +13,0 @@ const isPropertyNamedOnly = property => property && (property.name === 'only' || property.value === 'only');

'use strict';
const _require = require('./util'),
getDocsUrl = _require.getDocsUrl;
getDocsUrl = _require.getDocsUrl,
isHook = _require.isHook;

@@ -27,8 +28,2 @@ module.exports = {

create(context) {
const testHookNames = Object.assign(Object.create(null), {
beforeAll: true,
beforeEach: true,
afterAll: true,
afterEach: true
});
const whitelistedHookNames = (context.options[0] || {

@@ -41,4 +36,2 @@ allow: []

const isHook = node => testHookNames[node.callee.name];
const isWhitelisted = node => whitelistedHookNames[node.callee.name];

@@ -45,0 +38,0 @@

@@ -38,20 +38,5 @@ 'use strict';

const describeAliases = Object.assign(Object.create(null), {
describe: true,
'describe.only': true,
'describe.skip': true,
fdescribe: true,
xdescribe: true
});
const testCaseNames = Object.assign(Object.create(null), {
fit: true,
it: true,
'it.only': true,
'it.skip': true,
test: true,
'test.only': true,
'test.skip': true,
xit: true,
xtest: true
});
const describeAliases = new Set(['describe', 'describe.only', 'describe.skip', 'fdescribe', 'xdescribe']);
const testCaseNames = new Set(['fit', 'it', 'it.only', 'it.skip', 'test', 'test.only', 'test.skip', 'xit', 'xtest']);
const testHookNames = new Set(['beforeAll', 'beforeEach', 'afterAll', 'afterEach']);

@@ -81,6 +66,8 @@ const getNodeName = node => {

const isTestCase = node => node && node.type === 'CallExpression' && testCaseNames[getNodeName(node.callee)];
const isHook = node => node && node.type === 'CallExpression' && testHookNames.has(getNodeName(node.callee));
const isDescribe = node => node && node.type === 'CallExpression' && describeAliases[getNodeName(node.callee)];
const isTestCase = node => node && node.type === 'CallExpression' && testCaseNames.has(getNodeName(node.callee));
const isDescribe = node => node && node.type === 'CallExpression' && describeAliases.has(getNodeName(node.callee));
const isFunction = node => node && (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression');

@@ -213,2 +200,3 @@

isFunction,
isHook,
isTemplateLiteral,

@@ -215,0 +203,0 @@ isTestCase,

{
"name": "eslint-plugin-jest",
"version": "22.7.2",
"version": "22.8.0",
"description": "Eslint rules for Jest",

@@ -41,7 +41,7 @@ "repository": "jest-community/eslint-plugin-jest",

"@babel/preset-env": "^7.4.4",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@commitlint/cli": "^6.0.0",
"@commitlint/config-conventional": "^6.0.0",
"babel-jest": "^24.8.0",
"eslint": "^5.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-config-prettier": "^5.1.0",
"eslint-plugin-eslint-plugin": "^2.0.0",

@@ -48,0 +48,0 @@ "eslint-plugin-node": "^8.0.0",

@@ -6,3 +6,3 @@ [![Build Status](https://travis-ci.org/jest-community/eslint-plugin-jest.svg?branch=master)](https://travis-ci.org/jest-community/eslint-plugin-jest)

<a href="https://eslint.org/">
<img width="150" height="150" src="https://eslint.org/img/logo.svg">
<img width="150" height="150" src="https://eslint.org/assets/img/logo.svg">
</a>

@@ -116,2 +116,3 @@ <a href="https://facebook.github.io/jest/">

| [no-commented-out-tests][] | Disallow commented out tests | | |
| [no-duplicate-hooks][] | Disallow duplicate hooks withing a `describe` block | | |
| [no-empty-title][] | Disallow empty titles | | |

@@ -163,2 +164,3 @@ | [no-focused-tests][] | Disallow focused tests | ![recommended][] | |

[no-disabled-tests]: docs/rules/no-disabled-tests.md
[no-duplicate-hooks]: docs/rules/no-duplicate-hooks.md
[no-commented-out-tests]: docs/rules/no-commented-out-tests.md

@@ -165,0 +167,0 @@ [no-empty-title]: docs/rules/no-empty-title.md

@@ -8,3 +8,3 @@ 'use strict';

const ruleNames = Object.keys(rules);
const numberOfRules = 32;
const numberOfRules = 33;

@@ -11,0 +11,0 @@ describe('rules', () => {

@@ -5,12 +5,10 @@ 'use strict';

const testFunctions = Object.assign(Object.create(null), {
describe: true,
it: true,
test: true,
});
const testFunctions = new Set(['describe', 'it', 'test']);
const matchesTestFunction = object => object && testFunctions[object.name];
const matchesTestFunction = object => object && testFunctions.has(object.name);
const isCallToFocusedTestFunction = object =>
object && object.name[0] === 'f' && testFunctions[object.name.substring(1)];
object &&
object.name[0] === 'f' &&
testFunctions.has(object.name.substring(1));

@@ -17,0 +15,0 @@ const isPropertyNamedOnly = property =>

'use strict';
const { getDocsUrl } = require('./util');
const { getDocsUrl, isHook } = require('./util');

@@ -27,9 +27,2 @@ module.exports = {

create(context) {
const testHookNames = Object.assign(Object.create(null), {
beforeAll: true,
beforeEach: true,
afterAll: true,
afterEach: true,
});
const whitelistedHookNames = (

@@ -42,3 +35,2 @@ context.options[0] || { allow: [] }

const isHook = node => testHookNames[node.callee.name];
const isWhitelisted = node => whitelistedHookNames[node.callee.name];

@@ -45,0 +37,0 @@

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

const describeAliases = Object.assign(Object.create(null), {
describe: true,
'describe.only': true,
'describe.skip': true,
fdescribe: true,
xdescribe: true,
});
const describeAliases = new Set([
'describe',
'describe.only',
'describe.skip',
'fdescribe',
'xdescribe',
]);
const testCaseNames = Object.assign(Object.create(null), {
fit: true,
it: true,
'it.only': true,
'it.skip': true,
test: true,
'test.only': true,
'test.skip': true,
xit: true,
xtest: true,
});
const testCaseNames = new Set([
'fit',
'it',
'it.only',
'it.skip',
'test',
'test.only',
'test.skip',
'xit',
'xtest',
]);
const testHookNames = new Set([
'beforeAll',
'beforeEach',
'afterAll',
'afterEach',
]);
const getNodeName = node => {

@@ -123,6 +130,11 @@ function joinNames(a, b) {

const isHook = node =>
node &&
node.type === 'CallExpression' &&
testHookNames.has(getNodeName(node.callee));
const isTestCase = node =>
node &&
node.type === 'CallExpression' &&
testCaseNames[getNodeName(node.callee)];
testCaseNames.has(getNodeName(node.callee));

@@ -132,3 +144,3 @@ const isDescribe = node =>

node.type === 'CallExpression' &&
describeAliases[getNodeName(node.callee)];
describeAliases.has(getNodeName(node.callee));

@@ -230,2 +242,3 @@ const isFunction = node =>

isFunction,
isHook,
isTemplateLiteral,

@@ -232,0 +245,0 @@ isTestCase,

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