Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-testing-library

Package Overview
Dependencies
Maintainers
2
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-testing-library - npm Package Compare versions

Comparing version 6.2.0 to 6.2.1

5

dist/configs/index.js

@@ -7,2 +7,5 @@ "use strict";

const getConfigForFramework = (framework) => (0, utils_1.importDefault)((0, path_1.join)(configsDir, framework));
exports.default = utils_1.SUPPORTED_TESTING_FRAMEWORKS.reduce((allConfigs, framework) => (Object.assign(Object.assign({}, allConfigs), { [framework]: getConfigForFramework(framework) })), {});
exports.default = utils_1.SUPPORTED_TESTING_FRAMEWORKS.reduce((allConfigs, framework) => ({
...allConfigs,
[framework]: getConfigForFramework(framework),
}), {});

26

dist/create-testing-library-rule/index.js
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,6 +7,15 @@ exports.createTestingLibraryRule = void 0;

const detect_testing_library_utils_1 = require("./detect-testing-library-utils");
function createTestingLibraryRule(_a) {
var { create, detectionOptions = {}, meta } = _a, remainingConfig = __rest(_a, ["create", "detectionOptions", "meta"]);
return utils_1.ESLintUtils.RuleCreator(utils_2.getDocsUrl)(Object.assign(Object.assign({}, remainingConfig), { create: (0, detect_testing_library_utils_1.detectTestingLibraryUtils)(create, detectionOptions), meta: Object.assign(Object.assign({}, meta), { docs: Object.assign(Object.assign({}, meta.docs), { recommended: false }) }) }));
function createTestingLibraryRule({ create, detectionOptions = {}, meta, ...remainingConfig }) {
return utils_1.ESLintUtils.RuleCreator(utils_2.getDocsUrl)({
...remainingConfig,
create: (0, detect_testing_library_utils_1.detectTestingLibraryUtils)(create, detectionOptions),
meta: {
...meta,
docs: {
...meta.docs,
recommended: false,
},
},
});
}
exports.createTestingLibraryRule = createTestingLibraryRule;

@@ -144,27 +144,54 @@ "use strict";

const closestCallExpressionNode = findClosestCallExpressionNode(nodeIdentifier, true);
const suspiciousNodes = [nodeIdentifier, closestCallExpressionNode].filter(Boolean);
for (const node of suspiciousNodes) {
if (!(node === null || node === void 0 ? void 0 : node.parent)) {
continue;
}
if (utils_1.ASTUtils.isAwaitExpression(node.parent)) {
const callRootExpression = closestCallExpressionNode == null
? null
: getRootExpression(closestCallExpressionNode);
const suspiciousNodes = [nodeIdentifier, callRootExpression].filter((node) => node != null);
return suspiciousNodes.some((node) => {
if (!node.parent)
return false;
if (utils_1.ASTUtils.isAwaitExpression(node.parent))
return true;
}
if ((0, is_node_of_type_1.isArrowFunctionExpression)(node.parent) ||
(0, is_node_of_type_1.isReturnStatement)(node.parent)) {
(0, is_node_of_type_1.isReturnStatement)(node.parent))
return true;
}
if (hasClosestExpectResolvesRejects(node.parent)) {
if (hasClosestExpectResolvesRejects(node.parent))
return true;
}
if (hasChainedThen(node)) {
if (hasChainedThen(node))
return true;
}
if (isPromisesArrayResolved(node)) {
if (isPromisesArrayResolved(node))
return true;
});
}
exports.isPromiseHandled = isPromiseHandled;
function getRootExpression(expression) {
const { parent } = expression;
if (parent == null)
return expression;
switch (parent.type) {
case utils_1.AST_NODE_TYPES.ConditionalExpression:
return getRootExpression(parent);
case utils_1.AST_NODE_TYPES.LogicalExpression: {
let rootExpression;
switch (parent.operator) {
case '??':
case '||':
rootExpression = getRootExpression(parent);
break;
case '&&':
rootExpression =
parent.right === expression
? getRootExpression(parent)
: expression;
break;
}
return rootExpression !== null && rootExpression !== void 0 ? rootExpression : expression;
}
case utils_1.AST_NODE_TYPES.SequenceExpression:
return parent.expressions[parent.expressions.length - 1] === expression
? getRootExpression(parent)
: expression;
default:
return expression;
}
return false;
}
exports.isPromiseHandled = isPromiseHandled;
function getVariableReferences(context, node) {

@@ -171,0 +198,0 @@ var _a, _b, _c;

@@ -11,2 +11,5 @@ "use strict";

.filter((ruleName) => !excludedFiles.includes(ruleName))
.reduce((allRules, ruleName) => (Object.assign(Object.assign({}, allRules), { [ruleName]: (0, utils_1.importDefault)((0, path_1.join)(rulesDir, ruleName)) })), {});
.reduce((allRules, ruleName) => ({
...allRules,
[ruleName]: (0, utils_1.importDefault)((0, path_1.join)(rulesDir, ruleName)),
}), {});

@@ -55,3 +55,4 @@ "use strict";

property.init.value &&
property.init.value > 0);
Number.isInteger(property.init.value) &&
Number(property.init.value) > 0);
},

@@ -63,3 +64,4 @@ AssignmentExpression(node) {

node.right.value !== null) {
hasDelayDeclarationOrAssignmentGTZero = node.right.value > 0;
hasDelayDeclarationOrAssignmentGTZero =
Number.isInteger(node.right.value) && Number(node.right.value) > 0;
}

@@ -96,3 +98,4 @@ },

!!property.value.value &&
property.value.value > 0);
Number.isInteger(property.value.value) &&
Number(property.value.value) > 0);
const simulateEventFunctionName = simulateEventFunctionIdentifier.name;

@@ -99,0 +102,0 @@ if (USER_EVENT_ASYNC_EXCEPTIONS.includes(simulateEventFunctionName) &&

@@ -40,3 +40,6 @@ "use strict";

type: 'object',
properties: utils_2.DEBUG_UTILS.reduce((obj, name) => (Object.assign({ [name]: { type: 'boolean' } }, obj)), {}),
properties: utils_2.DEBUG_UTILS.reduce((obj, name) => ({
[name]: { type: 'boolean' },
...obj,
}), {}),
additionalProperties: false,

@@ -43,0 +46,0 @@ },

{
"name": "eslint-plugin-testing-library",
"version": "6.2.0",
"version": "6.2.1",
"description": "ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library",

@@ -70,6 +70,6 @@ "keywords": [

"eslint": "^8.38.0",
"eslint-config-kentcdodds": "^20.5.0",
"eslint-config-prettier": "^8.8.0",
"eslint-doc-generator": "^1.4.3",
"eslint-plugin-import": "^2.27.5",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.2.1",

@@ -90,3 +90,3 @@ "eslint-plugin-jest-formatting": "^3.1.0",

"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^5.0.4"
},

@@ -93,0 +93,0 @@ "peerDependencies": {

@@ -15,6 +15,6 @@ <div align="center">

[![Build status][build-badge]][build-url]
[![Package version][version-badge]][version-url]
[![eslint-remote-tester][eslint-remote-tester-badge]][eslint-remote-tester-workflow]
[![eslint-plugin-testing-library][package-health-badge]][package-health-url]
[![codecov](https://codecov.io/gh/testing-library/eslint-plugin-testing-library/graph/badge.svg?token=IJd6ZogYPm)](https://codecov.io/gh/testing-library/eslint-plugin-testing-library)
[![MIT License][license-badge]][license-url]

@@ -25,6 +25,2 @@ <br />

[![All Contributors][all-contributors-badge]](#contributors-)
<br />
[![Watch on Github][gh-watchers-badge]][gh-watchers-url]
[![Star on Github][gh-stars-badge]][gh-stars-url]
[![Tweet][tweet-badge]][tweet-url]

@@ -354,3 +350,3 @@ ## Installation

<tr>
<td align="center" valign="top" width="14.28%"><a href="https://mario.dev"><img src="https://avatars1.githubusercontent.com/u/2677072?v=4?s=100" width="100px;" alt="Mario Beltrán Alarcón"/><br /><sub><b>Mario Beltrán Alarcón</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3ABelco90" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Tests">⚠️</a> <a href="#infra-Belco90" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3ABelco90" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://mario.dev"><img src="https://avatars1.githubusercontent.com/u/2677072?v=4?s=100" width="100px;" alt="Mario Beltrán Alarcón"/><br /><sub><b>Mario Beltrán Alarcón</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3ABelco90" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Tests">⚠️</a> <a href="#infra-Belco90" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3ABelco90" title="Bug reports">🐛</a> <a href="#maintenance-Belco90" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://thomlom.dev"><img src="https://avatars3.githubusercontent.com/u/16003285?v=4?s=100" width="100px;" alt="Thomas Lombart"/><br /><sub><b>Thomas Lombart</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thomlom" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thomlom" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3Athomlom" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thomlom" title="Tests">⚠️</a> <a href="#infra-thomlom" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>

@@ -433,3 +429,7 @@ <td align="center" valign="top" width="14.28%"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4?s=100" width="100px;" alt="Ben Monro"/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=benmonro" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=benmonro" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=benmonro" title="Tests">⚠️</a></td>

<td align="center" valign="top" width="14.28%"><a href="https://github.com/doochik"><img src="https://avatars.githubusercontent.com/u/31961?v=4?s=100" width="100px;" alt="Aleksei Androsov"/><br /><sub><b>Aleksei Androsov</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=doochik" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=doochik" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/NicolasBonduel"><img src="https://avatars.githubusercontent.com/u/6507454?v=4?s=100" width="100px;" alt="Nicolas Bonduel"/><br /><sub><b>Nicolas Bonduel</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=NicolasBonduel" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://aryabov.com"><img src="https://avatars.githubusercontent.com/u/10157660?v=4?s=100" width="100px;" alt="Alexey Ryabov"/><br /><sub><b>Alexey Ryabov</b></sub></a><br /><a href="#maintenance-lesha1201" title="Maintenance">🚧</a></td>
</tr>
</tbody>

@@ -445,21 +445,13 @@ </table>

[build-badge]: https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/pipeline.yml/badge.svg
[build-url]: https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/pipeline.yml
[version-badge]: https://img.shields.io/npm/v/eslint-plugin-testing-library
[version-url]: https://www.npmjs.com/package/eslint-plugin-testing-library
[license-badge]: https://img.shields.io/npm/l/eslint-plugin-testing-library
[eslint-remote-tester-badge]: https://img.shields.io/github/workflow/status/AriPerkkio/eslint-remote-tester/eslint-plugin-testing-library?label=eslint-remote-tester
[eslint-remote-tester-workflow]: https://github.com/AriPerkkio/eslint-remote-tester/actions?query=workflow%3Aeslint-plugin-testing-library
[license-url]: https://github.com/testing-library/eslint-plugin-testing-library/blob/main/LICENSE
[eslint-remote-tester-badge]: https://img.shields.io/github/actions/workflow/status/AriPerkkio/eslint-remote-tester/lint-eslint-plugin-testing-library.yml
[eslint-remote-tester-workflow]: https://github.com/AriPerkkio/eslint-remote-tester/actions/workflows/lint-eslint-plugin-testing-library.yml
[package-health-badge]: https://snyk.io/advisor/npm-package/eslint-plugin-testing-library/badge.svg
[package-health-url]: https://snyk.io/advisor/npm-package/eslint-plugin-testing-library
[license-url]: https://github.com/testing-library/eslint-plugin-testing-library/blob/main/license
[pr-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/eslint-plugin-testing-library?color=orange&style=flat-square
[pr-url]: http://makeapullrequest.com
[gh-watchers-badge]: https://img.shields.io/github/watchers/testing-library/eslint-plugin-testing-library?style=social
[gh-watchers-url]: https://github.com/testing-library/eslint-plugin-testing-library/watchers
[gh-stars-badge]: https://img.shields.io/github/stars/testing-library/eslint-plugin-testing-library?style=social
[gh-stars-url]: https://github.com/testing-library/eslint-plugin-testing-library/stargazers
[tweet-badge]: https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Ftesting-library%2Feslint-plugin-testing-library
[tweet-url]: https://twitter.com/intent/tweet?url=https%3a%2f%2fgithub.com%2ftesting-library%2feslint-plugin-testing-library&text=check%20out%20eslint-plugin-testing-library%20by%20@belcodev
[badge-dom]: https://img.shields.io/badge/%F0%9F%90%99-DOM-black?style=flat-square

@@ -466,0 +458,0 @@ [badge-angular]: https://img.shields.io/badge/-Angular-black?style=flat-square&logo=angular&logoColor=white&labelColor=DD0031&color=black

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