Skip to content

extend non_constant_identifier_names for destructured variable declarations #58858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pq opened this issue Sep 8, 2022 · 2 comments · Fixed by dart-archive/linter#4084
Closed
Assignees
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-new-language-feature linter-set-core linter-set-recommended P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@pq
Copy link
Member

pq commented Sep 8, 2022

Destructuring doc.

Example:

BAD

var (LAT, LONG) = geoCode('Aarhus');

(double, double) geoCode(String city) => ...;

GOOD

var (lat, long) = geoCode('Aarhus');

(double, double) geoCode(String city) => ...;
@pq pq added linter-new-language-feature P1 A high priority bug; for example, a single project is unusable or has many test failures labels Sep 8, 2022
@pq
Copy link
Member Author

pq commented Sep 8, 2022

This should work for pattern-if statements too.

BAD

if (var [int X_COORD, int Y_COORD] = json) return Point(x, y);

GOOD

if (var [int xCoord, int yCoord] = json) return Point(x, y);

@pq
Copy link
Member Author

pq commented Sep 8, 2022

And pattern-for statements:

BAD

var fns = <Function()>[];
for (var (FIRST, SECOND) = (0, 1); FIRST <= 13; (FIRST, SECOND) = (SECOND, FIRST + SECOND)) {
  fns.add(() {
    print(FIRST);
  });
}

GOOD

var fns = <Function()>[];
for (var (a, b) = (0, 1); a <= 13; (a, b) = (b, a + b)) {
  fns.add(() {
    print(a);
  });
}

@pq pq self-assigned this Jan 5, 2023
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-new-language-feature linter-set-core linter-set-recommended P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants