@atlaskit/eslint-plugin-ui-styling-standard
Version:
The eslint plugin to enforce and educate on Atlassian's UI Styling Standard
17 lines (16 loc) • 685 B
JavaScript
/**
* TypeScript-only wrappers around an expression that ESTree does not model. None of them change
* the runtime value, so a rule reading a style key, value or argument should look through them:
*
* - `['.foo' satisfies `.${typeof FOO_CLASS}`]: {…}`
* - `color: 'red !important' as const`
* - `css({…} as const)`
* - `<T>{…}` and `value!`
*/
const TYPE_WRAPPER_TYPES = new Set(['TSAsExpression', 'TSNonNullExpression', 'TSSatisfiesExpression', 'TSTypeAssertion']);
/**
* Whether `node` is a TypeScript wrapper (`as`, `satisfies`, `<T>`, `!`) around an expression.
*/
export function isTypeWrapper(node) {
return Boolean(node && TYPE_WRAPPER_TYPES.has(node.type));
}