I have enabled the source.organizeImports option and it sorts the imports.
But the sort order is wrong with case-sensitivity, so phpcs for Drupal produces an error:

FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Tests\UnitTestCase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)

The correct order is:

use Drupal\Tests\UnitTestCase;
use Drupal\test_helpers\TestHelpers;
use Drupal\test_helpers\utils\AssertSequence;

But the extension puts the upper case letter at the end of the list:

use Drupal\test_helpers\TestHelpers;
use Drupal\test_helpers\utils\AssertSequence;
use Drupal\Tests\UnitTestCase;

Could you please fix this issue? Or provide an option to configure this behavior? Thanks!

Murz changed the title to Wrong case sensitive order of imports sort with organizeImports feature.

    Murz It looks more like a bug in phpcs, because the names should be case-insensitive.

      kp77 Alright! that makes sense.

      So basically we need to either respect that setting or at least to have our own setting.

      a month later

      We have added the setting "php.sortUses.caseSensitive". The setting will be available in the next update.

      Note, in the future, we'll start adding all the settings for code styling into the .editorconfig file (as we do for all the code formatting options) and respecting phpcs configuration as possible.

      Write a Reply...