UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

18 lines (17 loc) 775 B
import { findTokenNameByPropertyValue } from './find-token-name-by-property-value'; import { getTokenNodeForValue } from './get-token-node-for-value'; import { normaliseValue } from './normalise-value'; /** * Returns a stringifiable node with the token expression corresponding to its matching token. * If no token found for the pair the function returns undefined. * @param propertyName string camelCased css property. * @param value The computed value e.g '8px' -> '8'. */ export function getTokenReplacement(propertyName, value) { var tokenName = findTokenNameByPropertyValue(propertyName, value); if (!tokenName) { return undefined; } var fallbackValue = normaliseValue(propertyName, value); return getTokenNodeForValue(propertyName, fallbackValue); }