Custom regex does not work even though it is valid regex.


/.../.swiftlint.yml:26:31: error: scanner: while parsing a quoted scalar in line 26, column 12
found unknown escape character:
regex: "(\/\/ MARK: [^-])[\w\s]+\s+((func)|(var))"
^
Could not read configuration file at path '/.../.swiftlint.yml': file Configuration.swift, line 139
[1] 76069 abort swiftlint lint
swiftlint version to be sure)? 0.34.0# TextRecruit SwiftLint Configuration
disabled_rules: # rule identifiers to exclude from running
- large_tuple
- unused_optional_binding
- cyclomatic_complexity
- closure_parameter_position
- private_over_fileprivate
opt_in_rules: # some rules are only opt-in
# Find all the available rules by running:
# swiftlint rules
private_outlet
private_action
included: # paths to include during linting. `--path` is ignored if present.
- TextRecruit
- TextRecruitTests
- TextRecruitUITests
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- TextRecruit/Localization
# - Source/ExcludedFolder
# - Source/ExcludedFile.swiftb
custom_rules:
mark_format:
regex: "(\/\/ MARK: [^-])[\w\s]+\s+((func)|(var))"
match_kinds:
- comment
- identifier
name: "MARK Formatting"
message: "Use a '-' after the colon if marking a new group of methods or properties"
# configurable rules can be customized from this configuration file
# binary rules can set their severity level
trailing_whitespace:
ignores_empty_lines: true
force_cast: warning # implicitly
force_try:
severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 130
# they can set both implicitly with an array
type_body_length:
- 400 # warning
- 500 # error
# or they can set both explicitly
file_length:
warning: 700
error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
min_length: 1 # only warning
max_length: # warning and error
warning: 50
error: 60
excluded:
- iPhone # excluded via string
identifier_name:
min_length: 1 # only min_length
#error: 4 # only error
excluded: # excluded via string array
- id
- URL
- GlobalAPIKey
allowed_symbols:
- '_'
function_body_length:
- 120 # warning
- 120 # error
function_parameter_count: 6
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)
xcode-select -p)? 10.3echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rulesswiftlint lint --path [file here] --no-cache --enable-all-rules.// This triggers a violation:
let foo = try! bar()
This is not valid YAML. You can use ' instead of " when defining the regex and it should work.
Most helpful comment
This is not valid YAML. You can use
'instead of"when defining the regex and it should work.