missing-whitespace-between-adjacent-strings

Same as missing_whitespace_between_adjacent_strings in Dart lints

Group
Style
Path
lint/style/missing-whitespace-between-adjacent-strings
Default
On (recommended)
Origin
Dart lints
Rule
270 of 512
recommended

Flags adjacent string literals that join two words without a space between them.

When a part of an adjacent-string concatenation contains whitespace (so it reads as prose), neither it nor the next part supplying whitespace at the seam usually means a missing space:

var s = 'This string will be concatenated'  // flagged
    'with the next one.';
var s = 'This string will be concatenated '
    'with the next one.';                   // fine

An interpolation at the seam counts as whitespace. Strings passed straight to RegExp(...) or an unqualified matches(...) call are skipped, since patterns are split for readability rather than prose.

Invalid

example.dartdart
void use(Object o) {}

bool matches(String pattern) => pattern.isNotEmpty;

void main() {
  var name = 'Ann';
  use('This string will be concatenated'
      'with the next one.');
  use('Hello there' 'world');
  use('$name is' 'here');
  use('one two' 'three four'
      'five');
   use('line one' '''
line two''');
  use2(text: 'named arg' 'too');
}

void use2({required String text}) {}
Add whitespace between these adjacent strings.
6 var name = 'Ann';
7 use('This string will be concatenated'
Add whitespace between these adjacent strings.
8 'with the next one.');
9 use('Hello there' 'world');
Add whitespace between these adjacent strings.
9 use('Hello there' 'world');
10 use('$name is' 'here');
Add whitespace between these adjacent strings.
10 use('$name is' 'here');
11 use('one two' 'three four'
Add whitespace between these adjacent strings.
10 use('$name is' 'here');
11 use('one two' 'three four'
Add whitespace between these adjacent strings.
12 'five');
13 use('line one' '''
Add whitespace between these adjacent strings.
14line two''');
15 use2(text: 'named arg' 'too');

Valid

example.dartdart
void use(Object o) {}

bool matches(String pattern) => pattern.isNotEmpty;

void main() {
  var name = 'Ann';
  use('This string will be concatenated '
      'with the next one.');
  use('Hello' ' world');
  use('nospace' 'here');
  use('Name is ' '$name.');
  use('Name is' '${name}x');
  use('Name is' '$name.');
  use('Name is $name' 'x');
  use(RegExp('(foo bar)' '(baz)'));
  use(new RegExp('a b' 'c'));
  use(matches('a b' 'c'));
  use('tab\t' 'x');
}

Configure missing-whitespace-between-adjacent-strings

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "missing-whitespace-between-adjacent-strings": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/missing-whitespace-between-adjacent-strings: <reason>