Skip to content

dartfmt moved an // ignore: lint comment #838

Open
@jamesderlin

Description

@jamesderlin

Running dartfmt on:

void main() {
  try {
    print('hi');
  } on Error catch (e) { // ignore: avoid_catching_errors
    print('bye');
  }
}

generates:

void main() {
  try {
    print('hi');
  } on Error catch (e) {
    // ignore: avoid_catching_errors
    print('bye');
  }
}

And now the // ignore: comment is no longer referring to the intended line.

I don't think that this is quite the same as #546 since:

  1. The line doesn't need to be wrapped (it's shorter than 80 columns, and other than the presence of the comment, there's no other reason to split the line).
  2. I can't just add // ignore: to "the new lines if dartfmt splits something up".

I could move // ignore: to be above the targeted line, but I'd prefer not to since it then looks like the comment belongs in the try block. (That dartfmt indents the comment in that case doesn't help.)

(I am using dartfmt 1.2.8 on linux x64.)

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