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
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;
}
}void main() { use('A single-line string literal that is quite long but has no path separators.'); 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. */ /* 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'; 'a default view.' '${kIsWeb ? "\nSee: https://flutter.dev/to/web-multiview-runwidget" : ""}'; switch (value) { case '${"a/b"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': case '${"a/b"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': case '${"${"a/b"}"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':Valid
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.
{
"linter": {
"rules": {
"style": {
"lines-longer-than-80-chars": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/lines-longer-than-80-chars: <reason>More style rules
- map-keys-ordering
Flags literal string map keys that violate the configured order.
- matching-super-parameters
matching_super_parametersFlags positional super parameters named differently from the super constructor's corresponding parameter.
- member-ordering
member-orderingFlags class members declared out of the configured order.
- missing-whitespace-between-adjacent-strings
missing_whitespace_between_adjacent_stringsrecommendedFlags adjacent string literals that join two words without a space between them.
- newline-before-break
Requires a blank line before a break that follows another statement.
- newline-before-case
Requires a blank line between successive switch statement case clauses.
- newline-before-constructor
Requires a blank line before constructors following another member.
- newline-before-continue
Requires a blank line before a continue that follows another statement.