export default function calculateBoxModel()

in src/services/lintUtil.ts [174:252]


export default function calculateBoxModel(propertyTable: Element[]): BoxModel {
	const model: BoxModel = {
		top: { value: false, properties: [] },
		right: { value: false, properties: [] },
		bottom: { value: false, properties: [] },
		left: { value: false, properties: [] },
	};

	for (const property of propertyTable) {
		const value = property.node.value;
		if (typeof value === 'undefined') {
			continue;
		}

		switch (property.fullPropertyName) {
			case 'box-sizing':
				// has `box-sizing`, bail out
				return {
					top: { value: false, properties: [] },
					right: { value: false, properties: [] },
					bottom: { value: false, properties: [] },
					left: { value: false, properties: [] },
				};
			case 'width':
				model.width = property;
				break;
			case 'height':
				model.height = property;
				break;
			default:
				const segments = property.fullPropertyName.split('-');
				switch (segments[0]) {
					case 'border':
						switch (segments[1]) {
							case undefined:
							case 'top':
							case 'right':
							case 'bottom':
							case 'left':
								switch (segments[2]) {
									case undefined:
										updateModelWithValue(model, segments[1], checkBorderShorthand(value), property);
										break;
									case 'width':
										// the initial value of `border-width` is `medium`, not zero
										updateModelWithValue(model, segments[1], checkLineWidth(value, false), property);
										break;
									case 'style':
										// the initial value of `border-style` is `none`
										updateModelWithValue(model, segments[1], checkLineStyle(value, true), property);
										break;
								}
								break;
							case 'width':
								// the initial value of `border-width` is `medium`, not zero
								updateModelWithList(model, checkLineWidthList(value.getChildren(), false), property);
								break;
							case 'style':
								// the initial value of `border-style` is `none`
								updateModelWithList(model, checkLineStyleList(value.getChildren(), true), property);
								break;
						}
						break;
					case 'padding':
						if (segments.length === 1) {
							// the initial value of `padding` is zero
							updateModelWithList(model, checkLineWidthList(value.getChildren(), true), property);
						} else {
							// the initial value of `padding` is zero
							updateModelWithValue(model, segments[1], checkLineWidth(value, true), property);
						}
						break;
				}
				break;
		}
	}

	return model;
}