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 2.1.0 to 2.2.0

60

lib/rules/no-debug.js

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

const LIBRARY_MODULES_WITH_SCREEN = [
'@testing-library/dom',
'@testing-library/react',
'@testing-library/preact',
'@testing-library/vue',
'@testing-library/svelte',
];
module.exports = {

@@ -40,2 +48,4 @@ meta: {

let hasImportedScreen = false;
return {

@@ -62,2 +72,40 @@ VariableDeclarator(node) {

},
[`VariableDeclarator > CallExpression > Identifier[name="require"]`](
node
) {
const { arguments: args } = node.parent;
const literalNodeScreenModuleName = args.find(args =>
LIBRARY_MODULES_WITH_SCREEN.includes(args.value)
);
if (!literalNodeScreenModuleName) {
return;
}
const declaratorNode = node.parent.parent;
if (
declaratorNode.id.type === 'ObjectPattern' &&
declaratorNode.id.properties.some(
property => property.key.name === 'screen'
)
) {
hasImportedScreen = true;
}
},
ImportDeclaration(node) {
const screenModuleName = LIBRARY_MODULES_WITH_SCREEN.find(
module => module === node.source.value
);
if (
screenModuleName &&
node.specifiers.some(
specifier => specifier.imported.name === 'screen'
)
) {
hasImportedScreen = true;
}
},
[`CallExpression > Identifier[name="debug"]`](node) {

@@ -71,2 +119,14 @@ if (hasDestructuredDebugStatement) {

},
[`CallExpression > MemberExpression > Identifier[name="debug"]`](node) {
if (
hasImportedScreen &&
node.parent &&
node.parent.object.name === 'screen'
) {
context.report({
node,
messageId: 'noDebug',
});
}
},
'Program:exit'() {

@@ -73,0 +133,0 @@ renderVariableDeclarators.forEach(renderVar => {

2

package.json
{
"name": "eslint-plugin-testing-library",
"version": "2.1.0",
"version": "2.2.0",
"description": "ESLint rules for Testing Library",

@@ -5,0 +5,0 @@ "keywords": [

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