stylelint
Version:
A mighty CSS linter that helps you avoid errors and enforce conventions.
111 lines (101 loc) • 2.08 kB
JavaScript
import uniteSets from '../utils/uniteSets.mjs';
/** @type {ReadonlySet<string>} */
export const lengthUnits = new Set([
// Font-relative length units
'cap',
'ch',
'em',
'ex',
'ic',
'lh',
'rcap',
'rch',
'rem',
'rex',
'ric',
'rlh',
// Viewport-percentage lengths
'dvb',
'dvh',
'dvi',
'dvmax',
'dvmin',
'dvw',
'lvb',
'lvh',
'lvi',
'lvmax',
'lvmin',
'lvw',
'svb',
'svh',
'svi',
'svmax',
'svmin',
'svw',
'vb',
'vh',
'vi',
'vw',
'vmin',
'vmax',
'vm',
// Absolute length units
'px',
'mm',
'cm',
'in',
'pt',
'pc',
'q',
'mozmm',
// Flexible length units
'fr',
// Container query units
'cqw',
'cqh',
'cqi',
'cqb',
'cqmin',
'cqmax',
]);
/** @type {ReadonlySet<string>} */
export const resolutionUnits = new Set(['dpi', 'dpcm', 'dppx', 'x']);
/** @type {ReadonlyMap<string, { horizontalInline: string, verticalInline: string }>} */
export const physicalToFlowRelativeUnits = new Map([
// Viewport units (default)
['vw', { horizontalInline: 'vi', verticalInline: 'vb' }],
['vh', { horizontalInline: 'vb', verticalInline: 'vi' }],
// Viewport units (small)
['svw', { horizontalInline: 'svi', verticalInline: 'svb' }],
['svh', { horizontalInline: 'svb', verticalInline: 'svi' }],
// Viewport units (large)
['lvw', { horizontalInline: 'lvi', verticalInline: 'lvb' }],
['lvh', { horizontalInline: 'lvb', verticalInline: 'lvi' }],
// Viewport units (dynamic)
['dvw', { horizontalInline: 'dvi', verticalInline: 'dvb' }],
['dvh', { horizontalInline: 'dvb', verticalInline: 'dvi' }],
// Container query units
['cqw', { horizontalInline: 'cqi', verticalInline: 'cqb' }],
['cqh', { horizontalInline: 'cqb', verticalInline: 'cqi' }],
]);
/** @type {ReadonlySet<string>} */
export const flowRelativeUnits = new Set(
[...physicalToFlowRelativeUnits.values()].flatMap(Object.values),
);
/** @type {ReadonlySet<string>} */
export const units = uniteSets(lengthUnits, resolutionUnits, [
// Relative length units
'%',
// Time length units
's',
'ms',
// Angle
'deg',
'grad',
'turn',
'rad',
// Frequency
'Hz',
'kHz',
]);