How do I prevent a Node from being deleted? I want to make some checks and, under certain circumstances, prevent a node from being deleted.

My module makes checks in HOOK_form_BASE_FORM_ID_alter() when the node is being created, but I cannot see where I can get control when the node is being deleted.
Using hook_node_access() is one option:

use Drupal\Core\Entity\EntityInterface; 
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;

...

function MYMODULE_node_access(EntityInterface $entity, $operation, AccountInterface $account) {
  if ($operation == 'delete') {
    if (some_access_function($entity, $account)) {
      return AccessResult::allowed();
    }
    else {
      return AccessResult::forbidden();
    }
  }

  return AccessResult::neutral();
}


This method has the advantage of preventing deletion through other methods (e.g. REST) at the same time, and will automatically remove the delete link and tab from the node form anyway.