UNPKG

883 BJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.default = isStyledTag;
5
6var _hasAttrs = _interopRequireDefault(require("./hasAttrs"));
7
8function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
10const isAttrsExpression = (calleePath, pluginOptions) => (0, _hasAttrs.default)(calleePath) && // eslint-disable-next-line @typescript-eslint/no-use-before-define
11isStyledTag(calleePath.get('object'), pluginOptions);
12
13const isStyledExpression = (calleePath, {
14 styledTagName,
15 allowGlobal
16}) => styledTagName !== false && calleePath.node.name === styledTagName && (allowGlobal || calleePath.referencesImport('astroturf/react'));
17
18function isStyledTag(tagPath, pluginOptions) {
19 const callee = tagPath.get('callee');
20 return tagPath.isCallExpression() && (isAttrsExpression(callee, pluginOptions) || isStyledExpression(callee, pluginOptions));
21}
\No newline at end of file