diff --git a/common.json b/common.json index 103d4afb..757426aa 100644 --- a/common.json +++ b/common.json @@ -86,6 +86,7 @@ "one-var": [ "error", "always" ], "operator-linebreak": [ "error", "after" ], "prefer-numeric-literals": "error", + "prefer-regex-literals": "error", "quote-props": [ "error", "as-needed" ], "quotes": [ "error", "single", { "avoidEscape": true } ], "semi": [ "error", "always" ], diff --git a/test/fixtures/common/invalid.js b/test/fixtures/common/invalid.js index d8dff0d9..59a1cea5 100644 --- a/test/fixtures/common/invalid.js +++ b/test/fixtures/common/invalid.js @@ -194,6 +194,10 @@ var APP; concat: '4' + '2', // eslint-disable-next-line no-octal-escape octal: '\251', + // eslint-disable-next-line prefer-numeric-literals + numlit: parseInt( '1F7', 16 ), + // eslint-disable-next-line prefer-regex-literals + regex: new RegExp( 'abc', 'i' ), // eslint-disable-next-line no-script-url script: 'javascript:foo();', // eslint-disable-next-line no-unneeded-ternary diff --git a/test/fixtures/common/valid.js b/test/fixtures/common/valid.js index e05c8674..0057293b 100644 --- a/test/fixtures/common/valid.js +++ b/test/fixtures/common/valid.js @@ -5,7 +5,6 @@ // Rule: semi // Rule: semi-spacing // Rule: semi-style -// Rule: prefer-numeric-literals // Rule: unicode-bom ( function ( global ) { var APP, @@ -119,6 +118,7 @@ // Rule: one-var // Rule: vars-on-top var i, len, item, key, + // Rule: prefer-numeric-literals j = 1, ret = {}; @@ -179,6 +179,9 @@ options.enable = !!val; options.disable = Boolean( val ); + // Rule: prefer-regex-literals + options.pattern = /abc/i; + options.posX = +val; options.posY = Number( val );