lines-longer-than-80-chars

Same as lines_longer_than_80_chars in Dart lints

Group
Style
Path
lint/style/lines-longer-than-80-chars
Default
Off, opt in
Origin
Dart lints
Rule
255 of 512

Flags source lines longer than 80 characters.

Long lines are harder to read and to review side by side. Line length is counted in UTF-16 code units, excluding the line break and a leading byte order mark, and the diagnostic starts at the 81st character, where the line needs to wrap.

Lines that cannot reasonably be wrapped are exempt:

  • every line covered by a multiline (triple-quoted) string literal;
  • a line where a single-line string literal starts whose text contains / or \ (a URI or path); as in the analyzer, string literals nested in an interpolation are not considered;
  • a comment line (including comments inside interpolations) whose text contains / or \, and a // ignore: comment line.
// A comment that runs on and on and on and on and on and on and on and on.
//                                                    flagged ^ past column 80
// See https://github.com/dart-lang/sdk/blob/main/pkg/linter/doc/very/long.md
//                                  fine: the comment contains a URI ^

Invalid

example.dartdart
void use(Object o) {}

void main() {
  use('A single-line string literal that is quite long but has no path separators.');
  var aVeryLongVariableNameThatJustKeepsGoing = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;
  use(aVeryLongVariableNameThatJustKeepsGoing);
  /* Block comment text that is very long and keeps going and going past the limit. */
  use('héllo wörld with accents éééééééééééééééééééééééééééééééééééééééééééééééééé');
}

var nestedPath = '${"p/q"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

const kIsWeb = true;
var bindingMessage =
        'The app requested a view, but the platform did not provide one.\n'
        'Try using `runWidget` instead of `runApp` to start your app.\n'
        '`runWidget` allows you to provide a `View` widget, without requiring '
        'a default view.'
        '${kIsWeb ? "\nSee: https://flutter.dev/to/web-multiview-runwidget" : ""}';

void patternStrings(Object value) {
  switch (value) {
    case '${"a/b"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
    case '${"${"a/b"}"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
      break;
  }
}
The line length exceeds the 80-character limit.
3void main() {
4 use('A single-line string literal that is quite long but has no path separators.');
The line length exceeds the 80-character limit.
4 use('A single-line string literal that is quite long but has no path separators.');
5 var aVeryLongVariableNameThatJustKeepsGoing = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;
The line length exceeds the 80-character limit.
6 use(aVeryLongVariableNameThatJustKeepsGoing);
7 /* Block comment text that is very long and keeps going and going past the limit. */
The line length exceeds the 80-character limit.
7 /* Block comment text that is very long and keeps going and going past the limit. */
8 use('héllo wörld with accents éééééééééééééééééééééééééééééééééééééééééééééééééé');
The line length exceeds the 80-character limit.
10
11var nestedPath = '${"p/q"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
The line length exceeds the 80-character limit.
18 'a default view.'
19 '${kIsWeb ? "\nSee: https://flutter.dev/to/web-multiview-runwidget" : ""}';
The line length exceeds the 80-character limit.
22 switch (value) {
23 case '${"a/b"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
The line length exceeds the 80-character limit.
23 case '${"a/b"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
24 case '${"${"a/b"}"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':

Valid

example.dartdart
void use(Object o) {}

// See https://github.com/dart-lang/sdk/blob/main/pkg/linter/lib/src/rules/lines_longer.dart
/// Docs: https://dart.dev/tools/linter-rules/lines_longer_than_80_chars#details-and-more
void main() {
  use('https://example.com/a/very/long/path/that/cannot/be/wrapped/at/all/ok/really/long');
  use(r'C:\Users\someone\a\very\long\windows\path\that\is\long\too\x\y\z\w\v\u\t');
  use('''
A multiline string line that is very long and goes past the eighty limit here, way past.
''');
  // ignore: some_lint_name_that_is_long_enough_to_push_this_line_past_eighty_chars_ok
  /*
   * Block comment line with a path segment a/b that is long enough to exceed the limit.
   */
  use('short');
  use('éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé');
}

int a = 1;
var interpolationComment = '${a /* p/q */} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

Configure lines-longer-than-80-chars

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

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "lines-longer-than-80-chars": "error"
      }
    }
  }
}

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

example.dartdart
// falcon-ignore lint/style/lines-longer-than-80-chars: <reason>