Skip to content

Consider for var_with_no_type_annotatio for inclusion in core lintes #955

Open

Description

@natebosch

This lint aligns code with future language versions. Even considering code at existing language versions this is often a potential bug, or at best a style issue.

https://dart.dev/tools/linter-rules/var_with_no_type_annotation

I think we should include this in the core set and aim to publish the lint set once this lint is in a stable SDK release.

Activity

  1. lrhn commented on Apr 24, 2026

    @lrhn
    Member

    ACK. We should tell people to stop doing this (if they do, most don't anyway).

    It's a temporary lint. When the language makes it invalid to write var foo as a parameter, the lint will stop mattering. (Although it probably still exists for code written for pre-feature language versions as long as those are supported.)

    This should just be an analyzer warning. It's not something you should need to turn on or off, because nobody should turn it off. We want to scare people away from var and final in parameters as soon and decisively as possible.
    There should be a fix (which just removes the var or final), so nobody needs to stick with code that gets the warning longer than it takes to run dart fix.

    Nitpicking, the name and docs could be improved: "AVOID declaring parameters with var and no type annotation."
    You can't declare parameters with var and a type annotation, so this is just "avoid declaring parameters with var."
    The extra words are just confusing.

    (And you also shouldn't declare parameters with final.)

  2. natebosch commented on Jun 3, 2026

    @natebosch
    MemberAuthor

    Decision: Add to core set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions