use-raw-strings
Same as use_raw_strings in Dart lints
- Group
- Style
- Path
lint/style/use-raw-strings- Default
- Off, opt in
- Origin
- Dart lints
- Rule
- 498 of 512
Flags string literals whose only escapes are \\ and \$, which a raw
string would express without any backslash.
var s = 'A string with only \\ and \$'; // flagged
var s = r'A string with only \ and $'; // preferred
var s = 'tab\there \$'; // fine: `\t` needs a regular string
Interpolated literals are not checked, since a raw string cannot interpolate. Each part of an adjacent-string concatenation is checked on its own.
Invalid
void use(Object o) {}
void main() {
use('A string with only \\ and \$');
use('C:\\Users');
use("costs \$5");
use('''multi \\ line''');
use('ok' 'part \\');
}void main() { use('A string with only \\ and \$'); use('A string with only \\ and \$'); use('C:\\Users'); use('C:\\Users'); use("costs \$5"); use("costs \$5"); use('''multi \\ line'''); use('''multi \\ line'''); use('ok' 'part \\');Valid
void use(Object o) {}
void main() {
var x = 1;
use(r'A string with only \ and $');
use('tab\there \$');
use('it\'s');
use('no escapes');
use('\\ and $x');
use('\n');
}Configure use-raw-strings
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"use-raw-strings": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/use-raw-strings: <reason>More style rules
- use-setters-to-change-properties
use_setters_to_change_propertiesFlags one-parameter
voidmethods that only assign that parameter to a field. - use-spacer-as-expanded-child
use_spacer_as_expanded_childrecommendedflutterFlags an
Expandedwrapping an emptySizedBoxorContainerthat should be aSpacer. - use-string-in-part-of-directives
use_string_in_part_of_directivesrecommendedFlags a
part ofdirective that names its library instead of using a string URI. - use-super-parameters
use_super_parametersrecommendedPrefer super parameters when a constructor only forwards parameters to its superclass.
- use-test-throws-matchers
use_test_throws_matchersrecommendedPrefers
throwsAmatchers overtry { ...; fail(...); } catch (...) {}. - use-to-and-as-if-applicable
use_to_and_as_if_applicableFlags conversion methods not named
to…oras…. - always-declare-return-types
always_declare_return_typesrecommendedFlags functions and methods declared without a return type.
- always-put-control-body-on-new-line
always_put_control_body_on_new_lineFlags a control-flow body that starts on the same line as its control clause.