Skip to content

prefer_first & prefer_last #58343

@NatoBoram

Description

@NatoBoram

Describe the rule you'd like to see implemented

Include as much detail as you can.

Using users.first instead of users[0] isn't exactly that important, but it might be something that a team wants to enforce in order to be more consistent or adhering more to a "pick one and stick to it" philosophy.

I think this rule is the next logical step after prefer_is_empty and prefer_is_not_empty.

This should include a description of who would use the lint (such as if it's
specific to a framework like Flutter), what conditions the rule should look
for, and what conditions the rule should ignore.

Such a rule should catch users[0] as well as users[users.length - 1]

Examples

Ideally, provide motivating examples w/ rationale.

Additional context

Add any other considerations or context here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-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