main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Checks if the node is a React.createContext call
|
---|
5 | * @param {ASTNode} node - The AST node being checked.
|
---|
6 | * @returns {Boolean} - True if node is a React.createContext call, false if not.
|
---|
7 | */
|
---|
8 | module.exports = function isCreateContext(node) {
|
---|
9 | if (
|
---|
10 | node.init
|
---|
11 | && node.init.type === 'CallExpression'
|
---|
12 | && node.init.callee
|
---|
13 | && node.init.callee.name === 'createContext'
|
---|
14 | ) {
|
---|
15 | return true;
|
---|
16 | }
|
---|
17 |
|
---|
18 | if (
|
---|
19 | node.init
|
---|
20 | && node.init.callee
|
---|
21 | && node.init.callee.type === 'MemberExpression'
|
---|
22 | && node.init.callee.property
|
---|
23 | && node.init.callee.property.name === 'createContext'
|
---|
24 | ) {
|
---|
25 | return true;
|
---|
26 | }
|
---|
27 |
|
---|
28 | if (
|
---|
29 | node.expression
|
---|
30 | && node.expression.type === 'AssignmentExpression'
|
---|
31 | && node.expression.operator === '='
|
---|
32 | && node.expression.right.type === 'CallExpression'
|
---|
33 | && node.expression.right.callee
|
---|
34 | && node.expression.right.callee.name === 'createContext'
|
---|
35 | ) {
|
---|
36 | return true;
|
---|
37 | }
|
---|
38 |
|
---|
39 | if (
|
---|
40 | node.expression
|
---|
41 | && node.expression.type === 'AssignmentExpression'
|
---|
42 | && node.expression.operator === '='
|
---|
43 | && node.expression.right.type === 'CallExpression'
|
---|
44 | && node.expression.right.callee
|
---|
45 | && node.expression.right.callee.type === 'MemberExpression'
|
---|
46 | && node.expression.right.callee.property
|
---|
47 | && node.expression.right.callee.property.name === 'createContext'
|
---|
48 | ) {
|
---|
49 | return true;
|
---|
50 | }
|
---|
51 |
|
---|
52 | return false;
|
---|
53 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.