首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

wrap-regex

The --fix option on the command line can automatically fix some of the problems reported by this rule.

When a regular expression is used in certain situations, it can end up looking like a division operator. For example:

代码语言:javascript
复制
function a() {
    return /foo/.test("bar");
}

Rule Details

This is used to disambiguate the slash operator and facilitates more readable code.

Example of incorrect code for this rule:

代码语言:javascript
复制
/*eslint wrap-regex: "error"*/

function a() {
    return /foo/.test("bar");
}

Example of correct code for this rule:

代码语言:javascript
复制
/*eslint wrap-regex: "error"*/

function a() {
    return (/foo/).test("bar");
}

Version

This rule was introduced in ESLint 0.1.0.

Resources

代码语言:txt
复制
 © JS Foundation and other contributors

Licensed under the MIT License.

扫码关注腾讯云开发者

领取腾讯云代金券