UNPKG

@atlaskit/eslint-plugin-ui-styling-standard

Version:

The eslint plugin to enforce and educate on Atlassian's UI Styling Standard

31 lines • 980 B
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat'; import { findVariable } from '@atlaskit/eslint-utils/find-variable'; import { isSafeCss } from './is-safe-css'; import { isSafeKeyframes } from './is-safe-keyframes'; export function isSafeUsage(_ref) { var context = _ref.context, specifier = _ref.specifier, supportedImports = _ref.supportedImports; if (!('name' in specifier.imported)) { return false; } var importName = specifier.imported.name; if (!supportedImports.has(importName)) { return false; } if (importName === 'css') { var css = findVariable({ identifier: specifier.local, sourceCode: getSourceCode(context) }); return css !== null && isSafeCss(css); } if (importName === 'keyframes') { var keyframes = findVariable({ identifier: specifier.local, sourceCode: getSourceCode(context) }); return keyframes !== null && isSafeKeyframes(keyframes); } return true; }