Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

[Rule change] ignore method invocations in a variable declaration for prefer-moving-to-variableย #1142

Closed
@w3ggy

Description

@w3ggy

First of all. Thanks for amazing tool! We use flutter_hooks package on our project. When we add the prefer-moving-to-variable rule we see a lot of false-positive warnings related to hooks.

image

What rule do you want to change?
prefer-moving-to-variable

How will the change be implemented? (New option, new default behavior, etc.)?
Honestly, I don't know. It looks like we should use naming for omitting some function calls.

Please provide some example code that this change will affect:

    final key1 = useMemoized(() => GlobalKey<InputFieldState>(), []);
    final key2 = useMemoized(() => GlobalKey<InputFieldState>(), []);
    final key3 = useMemoized(() => GlobalKey<InputFieldState>(), []);
    final key4 = useMemoized(() => GlobalKey<InputFieldState>(), []);
    final key5 = useMemoized(() => GlobalKey<InputFieldState>(), []);

What does the rule currently do for this code?

Warns Prefer moving repeated invocations to variable and use it instead. (Documentation)

What will the rule do after it's changed?

It should skip hook validations

Are you willing to submit a pull request to implement this change?

I don't know how.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions