UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

46 lines (45 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isDecendantOfStyleBlock = void 0; var _isCssInJsCallNode = require("./is-css-in-js-call-node"); var _isCssInJsObjectNode = require("./is-css-in-js-object-node"); var _isCssInJsTemplateNode = require("./is-css-in-js-template-node"); var _isDecendantOfStyleBlock = exports.isDecendantOfStyleBlock = function isDecendantOfStyleBlock(node) { if (node.type === 'VariableDeclarator') { if (node.id.type !== 'Identifier') { return false; } if ( // @ts-ignore typeAnnotation is not defined by types node.id.typeAnnotation && // @ts-ignore typeAnnotation is not defined by types node.id.typeAnnotation.typeAnnotation.type === 'GenericTypeAnnotation' && // @ts-ignore typeAnnotation is not defined by types node.id.typeAnnotation.typeAnnotation.id.type === 'Identifier') { // @ts-ignore typeAnnotation is not defined by types var typeName = node.id.typeAnnotation.typeAnnotation.id.name; var hasCSSType = ['CSSProperties', 'CSSObject'].some(function (el) { return typeName.includes(el); }); if (hasCSSType) { return true; } } var varName = node.id.name.toLowerCase(); return ['style', 'css', 'theme'].some(function (el) { return varName.includes(el); }); } if ((0, _isCssInJsCallNode.isCssInJsCallNode)(node) || (0, _isCssInJsObjectNode.isCssInJsObjectNode)(node) || (0, _isCssInJsTemplateNode.isCssInJsTemplateNode)(node)) { return true; } if (node.type === 'TaggedTemplateExpression' && node.tag.type === 'Identifier' && node.tag.name === 'css') { return true; } if (node.parent) { return _isDecendantOfStyleBlock(node.parent); } return false; };