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 27.0.0-next.1 to 27.0.0-next.2

3

docs/rules/no-alias-methods.md
# Disallow alias methods (`no-alias-methods`)
> These aliases are going to be removed in the next major version of Jest - see
> https://github.com/facebook/jest/issues/13164 for more
Several Jest methods have alias names, such as `toThrow` having the alias of

@@ -4,0 +7,0 @@ `toThrowError`. This rule ensures that only the canonical name as used in the

15

docs/rules/no-restricted-matchers.md

@@ -11,4 +11,5 @@ # Disallow specific matchers & modifiers (`no-restricted-matchers`)

Both matchers, modifiers, and chains of the two are checked, allowing for
specific variations of a matcher to be banned if desired.
Bans are checked against the start of the `expect` chain - this means that to
ban a specific matcher entirely you must specify all six permutations, but
allows you to ban modifiers as well.

@@ -26,3 +27,8 @@ By default, this map is empty, meaning no matchers or modifiers are banned.

"resolves": "Use `expect(await promise)` instead.",
"not.toHaveBeenCalledWith": null
"toHaveBeenCalledWith": null,
"not.toHaveBeenCalledWith": null,
"resolves.toHaveBeenCalledWith": null,
"rejects.toHaveBeenCalledWith": null,
"resolves.not.toHaveBeenCalledWith": null,
"rejects.not.toHaveBeenCalledWith": null
}

@@ -37,2 +43,3 @@ ]

it('is false', () => {
// if this has a modifer (i.e. `not.toBeFalsy`), it would be considered fine
expect(a).toBeFalsy();

@@ -42,2 +49,3 @@ });

it('resolves', async () => {
// all uses of this modifier are disallowed, regardless of matcher
await expect(myPromise()).resolves.toBe(true);

@@ -48,2 +56,3 @@ });

it('does not upload the file', async () => {
// all uses of this matcher are disallowed
expect(uploadFileMock).not.toHaveBeenCalledWith('file.name');

@@ -50,0 +59,0 @@ });

@@ -16,3 +16,3 @@ "use strict";

description: 'Disallow alias methods',
recommended: false
recommended: 'error'
},

@@ -19,0 +19,0 @@ messages: {

@@ -26,3 +26,3 @@ "use strict";

messages: {
restrictedChain: 'Use of `{{ chain }}` is disallowed',
restrictedChain: 'Use of `{{ restriction }}` is disallowed',
restrictedChainWithMessage: '{{ message }}'

@@ -42,18 +42,6 @@ }

const permutations = [jestFnCall.members];
const chain = jestFnCall.members.map(nod => (0, _utils.getAccessorValue)(nod)).join('.');
if (jestFnCall.members.length > 2) {
permutations.push([jestFnCall.members[0], jestFnCall.members[1]]);
permutations.push([jestFnCall.members[1], jestFnCall.members[2]]);
}
if (jestFnCall.members.length > 1) {
permutations.push(...jestFnCall.members.map(nod => [nod]));
}
for (const permutation of permutations) {
const chain = permutation.map(nod => (0, _utils.getAccessorValue)(nod)).join('.');
if (chain in restrictedChains) {
const message = restrictedChains[chain];
for (const [restriction, message] of Object.entries(restrictedChains)) {
if (chain.startsWith(restriction)) {
context.report({

@@ -63,7 +51,7 @@ messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',

message,
chain
restriction
},
loc: {
start: permutation[0].loc.start,
end: permutation[permutation.length - 1].loc.end
start: jestFnCall.members[0].loc.start,
end: jestFnCall.members[jestFnCall.members.length - 1].loc.end
}

@@ -70,0 +58,0 @@ });

@@ -31,10 +31,2 @@ "use strict";

const tryCreateBaseRule = context => {
try {
return baseRule === null || baseRule === void 0 ? void 0 : baseRule.create(context);
} catch {
return null;
}
};
const DEFAULT_MESSAGE = 'This rule requires `@typescript-eslint/eslint-plugin`';

@@ -66,3 +58,3 @@

create(context) {
const baseSelectors = tryCreateBaseRule(context);
const baseSelectors = baseRule === null || baseRule === void 0 ? void 0 : baseRule.create(context);

@@ -69,0 +61,0 @@ if (!baseSelectors) {

{
"name": "eslint-plugin-jest",
"version": "27.0.0-next.1",
"version": "27.0.0-next.2",
"description": "ESLint rules for Jest",

@@ -106,4 +106,4 @@ "keywords": [

"@babel/preset-typescript": "^7.3.3",
"@commitlint/cli": "^16.0.0",
"@commitlint/config-conventional": "^16.0.0",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@schemastore/package": "^0.0.6",

@@ -114,7 +114,7 @@ "@semantic-release/changelog": "^6.0.0",

"@types/jest": "^28.0.0",
"@types/node": "^16.0.0",
"@types/node": "^14.18.26",
"@types/prettier": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"babel-jest": "^28.0.0",
"babel-jest": "^29.0.0",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",

@@ -125,13 +125,13 @@ "dedent": "^0.7.0",

"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-eslint-plugin": "^4.0.0",
"eslint-plugin-eslint-plugin": "^5.0.6",
"eslint-plugin-import": "^2.25.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "~0.0.5",
"husky": "^7.0.2",
"husky": "^8.0.1",
"is-ci": "^3.0.0",
"jest": "^28.0.0",
"jest-runner-eslint": "^1.0.0",
"lint-staged": "^12.0.0",
"jest": "^29.0.0",
"jest-runner-eslint": "^1.1.0",
"lint-staged": "^13.0.3",
"pinst": "^3.0.0",

@@ -138,0 +138,0 @@ "prettier": "^2.0.5",

@@ -206,3 +206,3 @@ <div align="center">

| [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![recommended][] | ![fixable][] |
| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |

@@ -221,3 +221,2 @@ | [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |

| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | |
| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |

@@ -224,0 +223,0 @@ | [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | |

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