Zend certified PHP/Magento developer

Magento 2 how to hide swatch on configurable product if it is out of stock?

I don’t use MSI and i want so that swatches that are not available are hidden on the configurable product.

How can this be done?