How can I add custom classes to each view's generated row?
If you look at /core/modules/views/views.theme.inc at template_preprocess_views_view_unformatted you'll see this code:

function template_preprocess_views_view_unformatted(&amp;$variables) {
  $view = $variables['view'];
  $rows = $variables['rows'];
  $style = $view-&gt;style_plugin;
  $options = $style-&gt;options;

  $variables['default_row_class'] = !empty($options['default_row_class']);
  foreach ($rows as $id =&gt; $row) {
    $variables['rows'][$id] = [];
    $variables['rows'][$id]['content'] = $row;
    $variables['rows'][$id]['attributes'] = new Attribute();
    if ($row_class = $view-&gt;style_plugin-&gt;getRowClass($id)) {
      $variables['rows'][$id]['attributes']-&gt;addClass($row_class);
    }
  }
}


This is how if you have set a row class in the view, it gets added.



And the resulting output:



You can copy this function to your custom module and customize it as you like.  For example, this will add the "views-row-" plus the name of your view cleaned up using the pathauto cleanstring utility:

function mymodule_preprocess_views_view_unformatted(&amp;$variables) {
  $view = $variables['view'];
  $rows = $variables['rows'];

  foreach ($rows as $id =&gt; $row) {
    // Add custom class to each row that encorporates the view id.
    $custom_row_class = \Drupal::service('pathauto.alias_cleaner')
      -&gt;cleanString($view-&gt;id());
    $custom_row_class = 'views-row-' . $custom_row_class;
    $variables['rows'][$id]['attributes']-&gt;addClass($custom_row_class);
  }
}


If you would like to add classes to a views rows from hook_preprocess_views_view, you can do it this way:

function mitsloan_global_preprocess_views_view(&amp;$variables) {
  $view = $variables['view'];

  if ($view-&gt;id() == 'testview') {

    $row_style_plugin = &amp;$variables['rows'][0]['#view']-&gt;style_plugin;

    $custom_row_class = 'views-row-' . \Drupal::service('pathauto.alias_cleaner')
        -&gt;cleanString($view-&gt;id());

    $row_style_plugin-&gt;options['row_class'] = $custom_row_class;
  }

}