跳到主要內容

unnecessary_string_escapes

穩定
建議
可修正

移除字串中不必要的反斜線。

詳細資訊

#

移除字串中不必要的反斜線。

錯誤範例

dart
'this string contains 2 \"double quotes\" ';
"this string contains 2 \'single quotes\' ";

正確範例

dart
'this string contains 2 "double quotes" ';
"this string contains 2 'single quotes' ";

啟用

#

若要啟用 unnecessary_string_escapes 規則,請在您的 analysis_options.yaml 檔案中的 linter > rules 下新增 unnecessary_string_escapes

analysis_options.yaml
yaml
linter:
  rules:
    - unnecessary_string_escapes

如果您改為使用 YAML 對應語法來設定 linter 規則,請在 linter > rules 下新增 unnecessary_string_escapes: true

analysis_options.yaml
yaml
linter:
  rules:
    unnecessary_string_escapes: true