@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
20 lines • 891 B
JavaScript
import { isNodeOfType } from 'eslint-codemod-utils';
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
import { Root } from '../../ast-nodes/root';
var _isDecendantOfPrimitive = function isDecendantOfPrimitive(node, context) {
var primitivesToCheck = ['Box', 'Text', 'Tile'];
if (isNodeOfType(node, 'JSXElement')) {
// @ts-ignore
if (primitivesToCheck.includes(node.openingElement.name.name)) {
var importDeclaration = Root.findImportsByModule(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;
};
export { _isDecendantOfPrimitive as isDecendantOfPrimitive };