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
3
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 5.7.0 to 5.7.1

26

create-testing-library-rule/detect-testing-library-utils.js

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

return (context, optionsWithDefault) => {
let importedTestingLibraryNode = null;
const importedTestingLibraryNodes = [];
let importedCustomModuleNode = null;

@@ -79,4 +79,7 @@ let importedUserEventLibraryNode = null;

const getTestingLibraryImportNode = () => {
return importedTestingLibraryNode;
return importedTestingLibraryNodes[0];
};
const getAllTestingLibraryImportNodes = () => {
return importedTestingLibraryNodes;
};
const getCustomModuleImportNode = () => {

@@ -86,3 +89,3 @@ return importedCustomModuleNode;

const getTestingLibraryImportName = () => {
return (0, node_utils_1.getImportModuleName)(importedTestingLibraryNode);
return (0, node_utils_1.getImportModuleName)(importedTestingLibraryNodes[0]);
};

@@ -93,3 +96,3 @@ const getCustomModuleImportName = () => {

const isTestingLibraryImported = (isStrict = false) => {
const isSomeModuleImported = !!importedTestingLibraryNode || !!importedCustomModuleNode;
const isSomeModuleImported = importedTestingLibraryNodes.length !== 0 || !!importedCustomModuleNode;
return ((!isStrict && isAggressiveModuleReportingEnabled()) ||

@@ -428,2 +431,3 @@ isSomeModuleImported);

getTestingLibraryImportNode,
getAllTestingLibraryImportNodes,
getCustomModuleImportNode,

@@ -463,5 +467,4 @@ getTestingLibraryImportName,

}
if (!importedTestingLibraryNode &&
/testing-library/g.test(node.source.value)) {
importedTestingLibraryNode = node;
if (/testing-library/g.test(node.source.value)) {
importedTestingLibraryNodes.push(node);
}

@@ -486,7 +489,6 @@ const customModule = getCustomModule();

const { arguments: args } = callExpression;
if (!importedTestingLibraryNode &&
args.some((arg) => (0, node_utils_1.isLiteral)(arg) &&
typeof arg.value === 'string' &&
/testing-library/g.test(arg.value))) {
importedTestingLibraryNode = callExpression;
if (args.some((arg) => (0, node_utils_1.isLiteral)(arg) &&
typeof arg.value === 'string' &&
/testing-library/g.test(arg.value))) {
importedTestingLibraryNodes.push(callExpression);
}

@@ -493,0 +495,0 @@ const customModule = getCustomModule();

{
"name": "eslint-plugin-testing-library",
"version": "5.7.0",
"version": "5.7.1",
"description": "ESLint rules for Testing Library",

@@ -66,3 +66,3 @@ "keywords": [

"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "^0.0.6",
"eslint-remote-tester-repositories": "^0.0.7",
"husky": "^8.0.1",

@@ -69,0 +69,0 @@ "is-ci": "^3.0.1",

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

<td align="center"><a href="https://github.com/sjarva"><img src="https://avatars.githubusercontent.com/u/1133238?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Senja</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=sjarva" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=sjarva" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=sjarva" title="Documentation">📖</a></td>
<td align="center"><a href="https://dbrno.vercel.app"><img src="https://avatars.githubusercontent.com/u/106157862?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Breno Cota</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=brenocota-hotmart" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=brenocota-hotmart" title="Tests">⚠️</a></td>
</tr>

@@ -416,0 +417,0 @@ </tbody>

@@ -66,12 +66,12 @@ "use strict";

'Program:exit'() {
const importName = helpers.getTestingLibraryImportName();
const importNode = helpers.getTestingLibraryImportNode();
if (!importNode) {
return;
}
const domModuleName = DOM_TESTING_LIBRARY_MODULES.find((module) => module === importName);
if (!domModuleName) {
return;
}
report(importNode, domModuleName);
let importName;
const allImportNodes = helpers.getAllTestingLibraryImportNodes();
allImportNodes.forEach((importNode) => {
importName = (0, node_utils_1.getImportModuleName)(importNode);
const domModuleName = DOM_TESTING_LIBRARY_MODULES.find((module) => module === importName);
if (!domModuleName) {
return;
}
report(importNode, domModuleName);
});
},

@@ -78,0 +78,0 @@ };

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