summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/wrap-regex.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/lib/rules/wrap-regex.js')
-rw-r--r--tools/eslint/lib/rules/wrap-regex.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/eslint/lib/rules/wrap-regex.js b/tools/eslint/lib/rules/wrap-regex.js
index 71cfa06a75..79f3d30515 100644
--- a/tools/eslint/lib/rules/wrap-regex.js
+++ b/tools/eslint/lib/rules/wrap-regex.js
@@ -17,7 +17,9 @@ module.exports = {
recommended: false
},
- schema: []
+ schema: [],
+
+ fixable: "code"
},
create(context) {
@@ -36,7 +38,11 @@ module.exports = {
if (grandparent.type === "MemberExpression" && grandparent.object === node &&
(!source || source.value !== "(")) {
- context.report(node, "Wrap the regexp literal in parens to disambiguate the slash.");
+ context.report({
+ node,
+ message: "Wrap the regexp literal in parens to disambiguate the slash.",
+ fix: fixer => fixer.replaceText(node, `(${sourceCode.getText(node)})`)
+ });
}
}
}