HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //var/www/html/orbi-individual/node_modules/eslint-plugin-react/lib/util/isCreateContext.js
'use strict';

/**
 * Checks if the node is a React.createContext call
 * @param {ASTNode} node - The AST node being checked.
 * @returns {Boolean} - True if node is a React.createContext call, false if not.
 */
module.exports = function isCreateContext(node) {
  if (
    node.init
    && node.init.type === 'CallExpression'
    && node.init.callee
    && node.init.callee.name === 'createContext'
  ) {
    return true;
  }

  if (
    node.init
    && node.init.callee
    && node.init.callee.type === 'MemberExpression'
    && node.init.callee.property
    && node.init.callee.property.name === 'createContext'
  ) {
    return true;
  }

  if (
    node.expression
    && node.expression.type === 'AssignmentExpression'
    && node.expression.operator === '='
    && node.expression.right.type === 'CallExpression'
    && node.expression.right.callee
    && node.expression.right.callee.name === 'createContext'
  ) {
    return true;
  }

  if (
    node.expression
    && node.expression.type === 'AssignmentExpression'
    && node.expression.operator === '='
    && node.expression.right.type === 'CallExpression'
    && node.expression.right.callee
    && node.expression.right.callee.type === 'MemberExpression'
    && node.expression.right.callee.property
    && node.expression.right.callee.property.name === 'createContext'
  ) {
    return true;
  }

  return false;
};