UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

20 lines 564 B
var emRegex = /(.*\d+)em$/; var invalidSpacingUnitRegex = /(\d+rem$)|(vw$)|(vh$)/; export var isValidSpacingValue = function isValidSpacingValue(value, fontSize) { if (typeof value === 'string') { if (invalidSpacingUnitRegex.test(value)) { return false; } } else if (Array.isArray(value)) { // could be array due to shorthand for (var val in value) { if (invalidSpacingUnitRegex.test(val)) { return false; } } } if (emRegex.test(value) && typeof fontSize !== 'number') { return false; } return true; };