diff --git a/lib/linter.js b/lib/linter.js index 8f1520aafb47..31513ff3d60e 100755 --- a/lib/linter.js +++ b/lib/linter.js @@ -337,7 +337,11 @@ function modifyConfigsFromComments(filename, ast, config, linterContext) { if (parseResult.success) { Object.keys(parseResult.config).forEach(name => { - const ruleValue = parseResult.config[name]; + let ruleValue = parseResult.config[name]; + + if (typeof ruleValue === "string") { + ruleValue = ruleValue.replace(/\\/g, "\\\\"); + } validator.validateRuleOptions(name, ruleValue, `${filename} line ${comment.loc.start.line}`, linterContext.rules); commentRules[name] = ruleValue;