Skip to content

Update "Import library" correction to account for linter rules #53819

@Mike278

Description

@Mike278

Dart SDK version: 3.3.0-48.0.dev (dev) (Fri Oct 20 09:02:07 2023 -0700) on "windows_x64"

Steps to reproduce:

  • Create a new dart project
  • Replace the contents of analysis_options.yaml with
linter:
  rules:
    prefer_relative_imports: false
    avoid_relative_lib_imports: true # Probably redundant
    always_use_package_imports: true # Probably redundant
  • Create a new file lib/foo.dart with contents const hello = 'world';
  • Create a new file lib/bar.dart with contents const greeting = hello;
  • Open the project in IntelliJ and enable Dart support (I haven't tested this in any other editor)
  • Navigate to lib/bar.dart, place the cursor on hello, and generate suggestions with alt+enter
  • Expected: Import library 'package:import_bug/foo.dart' is the first (and ideally, only) suggestion
  • Actual:
    image

This function seems to suggest the order depends on the value of prefer_relative_imports, but changing this value doesn't change the order.

Might be related to #32916 where support for relative imports was added?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-completionIssues with the analysis server's code completion featuretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions