UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

32 lines (29 loc) 994 B
import { isNodeOfType } from 'eslint-codemod-utils'; import { getSourceCode } from '@atlaskit/eslint-utils/context-compat'; import { getModuleOfIdentifier } from '../../utils/get-module-of-identifier'; import { isBlockedEventBinding } from '../shared/is-blocked-event-binding'; export function isBlockedBind(context, node) { const callee = node.callee; if (!isNodeOfType(callee, 'Identifier')) { return false; } if (callee.name !== 'bind') { return false; } const module = getModuleOfIdentifier(getSourceCode(context), 'bind'); if ((module === null || module === void 0 ? void 0 : module.moduleName) !== 'bind-event-listener') { return false; } const secondArg = node.arguments[1]; if (!isNodeOfType(secondArg, 'ObjectExpression')) { return false; } // using a for loop for speed 🚀 for (const property of secondArg.properties) { if (isBlockedEventBinding(property)) { return true; } } // no exit conditions hit return false; }