leading-newlines-in-multiline-strings
Same as leading_newlines_in_multiline_strings in Dart lints
- Group
- Style
- Path
lint/style/leading-newlines-in-multiline-strings- Default
- Off, opt in
- Origin
- Dart lints
- Rule
- 250 of 512
Flags a multiline string spanning several lines whose text does not start with a line break right after the opening quotes.
Starting the text on its own line keeps every line aligned at the same indentation, and Dart drops that first line break from the value:
var s1 = '''{
"a": 1
}'''; // flagged
var s2 = '''
{
"a": 1
}'''; // preferred
Triple-quoted literals that stay on one line are not flagged.
Invalid
void use(Object o) {}
void main() {
var name = 'Ann';
use('''{
"a": 1
}''');
use("""first line
second line""");
use(r'''raw first
raw second''');
use('''$name
interpolated''');
use('a' '''b
adjacent part''');
} var name = 'Ann'; use('''{}'''); use("""first linesecond line"""); use(r'''raw firstraw second'''); use('''$nameinterpolated'''); use('a' '''bValid
void use(Object o) {}
void main() {
var name = 'Ann';
use('''
{
"a": 1
}''');
use('''single line''');
use("""
second""");
use(r'''
raw''');
use('''
$name''');
use('not multiline');
}Configure leading-newlines-in-multiline-strings
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"leading-newlines-in-multiline-strings": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/leading-newlines-in-multiline-strings: <reason>More style rules
- library-annotations
library_annotationsrecommendedRequires library-targeted metadata to attach to a
librarydirective. - library-names
library_namesrecommendedFlags a library name that is not
lowercase_with_underscores. - library-prefixes
library_prefixesrecommendedFlags import prefixes that are not
lower_case_with_underscores. - lines-longer-than-80-chars
lines_longer_than_80_charsFlags source lines longer than 80 characters.
- 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.