passsy / dart-lint

An opinionated, community-driven set of lint rules for Dart and Flutter projects. Like pedantic but stricter
Apache License 2.0
277 stars 82 forks source link

False positive: unecessary_string_escapes #66

Closed mfizz1 closed 1 year ago

mfizz1 commented 1 year ago
RegExp(
  r'(\s)'
  '?(foo|bar)(\s)?',
  caseSensitive: false,
),

the third matching group (\s) is incorrectly identified as unecessary_string_escapes

passsy commented 1 year ago

The warning is correct. You miss the r in the second line

    RegExp(
      r'(\s)'
      r'?(foo|bar)(\s)?',
      caseSensitive: false,
    );

Without the r you have to use \\

    RegExp(
      r'(\s)'
      '?(foo|bar)(\\s)?',
      caseSensitive: false,
    );
mfizz1 commented 1 year ago

My mistake! I thought with the line continuation, the r from the first line would have been sufficient.