UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

25 lines (24 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isDecendantOfPrimitive = void 0; var _eslintCodemodUtils = require("eslint-codemod-utils"); var _contextCompat = require("@atlaskit/eslint-utils/context-compat"); var _root = require("../../ast-nodes/root"); var _isDecendantOfPrimitive = exports.isDecendantOfPrimitive = function isDecendantOfPrimitive(node, context) { var primitivesToCheck = ['Box', 'Text', 'Tile']; if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) { // @ts-ignore if (primitivesToCheck.includes(node.openingElement.name.name)) { var importDeclaration = _root.Root.findImportsByModule((0, _contextCompat.getSourceCode)(context).ast.body, ['@atlaskit/primitives', '@atlaskit/primitives/box', '@atlaskit/primitives/text', '@atlaskit/primitives/compiled', '@atlaskit/tile']); if (importDeclaration.length) { return true; } } } if (node.parent) { return _isDecendantOfPrimitive(node.parent, context); } return false; };