From f71b5ee3d03fac50358456a938e655b31d79792a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Sat, 30 Sep 2017 00:39:40 +0800 Subject: [PATCH] Fix: id-match mysteriously fails when defined in a comment. (fixes #9366) --- lib/linter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;