main
Last change
on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
894 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | const pragmaUtil = require('./pragma');
|
---|
4 | const isDestructuredFromPragmaImport = require('./isDestructuredFromPragmaImport');
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Checks if the node is a createElement call
|
---|
8 | * @param {Context} context - The AST node being checked.
|
---|
9 | * @param {ASTNode} node - The AST node being checked.
|
---|
10 | * @returns {boolean} - True if node is a createElement call object literal, False if not.
|
---|
11 | */
|
---|
12 | module.exports = function isCreateElement(context, node) {
|
---|
13 | if (!node.callee) {
|
---|
14 | return false;
|
---|
15 | }
|
---|
16 |
|
---|
17 | if (
|
---|
18 | node.callee.type === 'MemberExpression'
|
---|
19 | && node.callee.property.name === 'createElement'
|
---|
20 | && node.callee.object
|
---|
21 | && node.callee.object.name === pragmaUtil.getFromContext(context)
|
---|
22 | ) {
|
---|
23 | return true;
|
---|
24 | }
|
---|
25 |
|
---|
26 | if (
|
---|
27 | node.callee.name === 'createElement'
|
---|
28 | && isDestructuredFromPragmaImport(context, node, 'createElement')
|
---|
29 | ) {
|
---|
30 | return true;
|
---|
31 | }
|
---|
32 |
|
---|
33 | return false;
|
---|
34 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.