Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const astUtil = require('./ast');
|
|
|
|
/**
|
|
* 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.callee
|
|
) {
|
|
if (
|
|
astUtil.isCallExpression(node.init)
|
|
&& node.init.callee.name === 'createContext'
|
|
) {
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
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 === '='
|
|
&& astUtil.isCallExpression(node.expression.right)
|
|
&& node.expression.right.callee
|
|
) {
|
|
const right = node.expression.right;
|
|
|
|
if (right.callee.name === 'createContext') {
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
right.callee.type === 'MemberExpression'
|
|
&& right.callee.property
|
|
&& right.callee.property.name === 'createContext'
|
|
) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
};
|