You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

eslint-plugin-testing-library

Package Overview
Dependencies
Maintainers
2
Versions
183
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

to
7.4.0

8

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

@@ -335,4 +335,4 @@ "use strict";

return isNegated
? utils_2.ABSENCE_MATCHERS.includes(matcher)
: utils_2.PRESENCE_MATCHERS.includes(matcher);
? utils_2.ABSENCE_MATCHERS.some((absenceMather) => absenceMather === matcher)
: utils_2.PRESENCE_MATCHERS.some((presenceMather) => presenceMather === matcher);
};

@@ -345,4 +345,4 @@ const isAbsenceAssert = (node) => {

return isNegated
? utils_2.PRESENCE_MATCHERS.includes(matcher)
: utils_2.ABSENCE_MATCHERS.includes(matcher);
? utils_2.PRESENCE_MATCHERS.some((presenceMather) => presenceMather === matcher)
: utils_2.ABSENCE_MATCHERS.some((absenceMather) => absenceMather === matcher);
};

@@ -349,0 +349,0 @@ const isMatchingAssert = (node, matcherName) => {

@@ -7,6 +7,13 @@ "use strict";

const detect_testing_library_utils_1 = require("./detect-testing-library-utils");
const createTestingLibraryRule = ({ create, detectionOptions = {}, ...remainingConfig }) => utils_1.ESLintUtils.RuleCreator(utils_2.getDocsUrl)({
...remainingConfig,
create: (0, detect_testing_library_utils_1.detectTestingLibraryUtils)(create, detectionOptions),
});
const createTestingLibraryRule = ({ create, detectionOptions = {}, ...remainingConfig }) => {
const rule = utils_1.ESLintUtils.RuleCreator(utils_2.getDocsUrl)({
...remainingConfig,
create: (0, detect_testing_library_utils_1.detectTestingLibraryUtils)(create, detectionOptions),
});
const { docs } = rule.meta;
if (docs === undefined) {
throw new Error('Rule metadata must contain `docs` property');
}
return { ...rule, meta: { ...rule.meta, docs } };
};
exports.createTestingLibraryRule = createTestingLibraryRule;

@@ -47,5 +47,8 @@ "use strict";

}
if (utils_1.ASTUtils.isIdentifier(node.property) &&
utils_2.ALL_RETURNING_NODES.includes(node.property.name)) {
if (allowContainerFirstChild && node.property.name === 'firstChild') {
const propertyName = utils_1.ASTUtils.isIdentifier(node.property)
? node.property.name
: null;
if (propertyName &&
utils_2.ALL_RETURNING_NODES.some((allReturningNode) => allReturningNode === propertyName)) {
if (allowContainerFirstChild && propertyName === 'firstChild') {
return;

@@ -52,0 +55,0 @@ }

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

allowTestingFrameworkSetupHook: {
enum: utils_2.TESTING_FRAMEWORK_SETUP_HOOKS,
enum: [...utils_2.TESTING_FRAMEWORK_SETUP_HOOKS],
type: 'string',

@@ -50,0 +50,0 @@ },

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

type: 'string',
enum: utils_2.PRESENCE_MATCHERS,
enum: [...utils_2.PRESENCE_MATCHERS],
},

@@ -141,4 +141,6 @@ includeFindQueries: { type: 'boolean' },

}
const shouldEnforceAssertion = (!isNegatedMatcher && utils_2.PRESENCE_MATCHERS.includes(matcher)) ||
(isNegatedMatcher && utils_2.ABSENCE_MATCHERS.includes(matcher));
const shouldEnforceAssertion = (!isNegatedMatcher &&
utils_2.PRESENCE_MATCHERS.some((presenceMather) => presenceMather === matcher)) ||
(isNegatedMatcher &&
utils_2.ABSENCE_MATCHERS.some((absenceMather) => absenceMather === matcher));
if (shouldEnforceAssertion && matcher !== assertion) {

@@ -145,0 +147,0 @@ context.report({

@@ -25,2 +25,3 @@ "use strict";

},
fixable: 'code',
schema: [

@@ -53,3 +54,3 @@ {

const withinCallNode = (0, node_utils_1.findClosestCallNode)(node, 'within');
if (!expectCallNode || !(0, node_utils_1.isMemberExpression)(expectCallNode.parent)) {
if (!(0, node_utils_1.isMemberExpression)(expectCallNode === null || expectCallNode === void 0 ? void 0 : expectCallNode.parent)) {
return;

@@ -70,3 +71,8 @@ }

!isPresenceQuery) {
context.report({ node, messageId: 'wrongPresenceQuery' });
const newQueryName = node.name.replace(/^query/, 'get');
context.report({
node,
messageId: 'wrongPresenceQuery',
fix: (fixer) => fixer.replaceText(node, newQueryName),
});
}

@@ -77,3 +83,8 @@ else if (!withinCallNode &&

isPresenceQuery) {
context.report({ node, messageId: 'wrongAbsenceQuery' });
const newQueryName = node.name.replace(/^get/, 'query');
context.report({
node,
messageId: 'wrongAbsenceQuery',
fix: (fixer) => fixer.replaceText(node, newQueryName),
});
}

@@ -80,0 +91,0 @@ },

@@ -44,3 +44,8 @@ "use strict";

exports.LIBRARY_MODULES = LIBRARY_MODULES;
const SYNC_QUERIES_VARIANTS = ['getBy', 'getAllBy', 'queryBy', 'queryAllBy'];
const SYNC_QUERIES_VARIANTS = [
'getBy',
'getAllBy',
'queryBy',
'queryAllBy',
];
exports.SYNC_QUERIES_VARIANTS = SYNC_QUERIES_VARIANTS;

@@ -47,0 +52,0 @@ const ASYNC_QUERIES_VARIANTS = ['findBy', 'findAllBy'];

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

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

Sorry, the diff of this file is too big to display