Skip to content

Commit

Permalink
update eslint-plugin-regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed May 8, 2021
1 parent 4859406 commit c7170fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
12 changes: 9 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ const base = {
'regexp/confusing-quantifier': 'error',
// enforce consistent escaping of control characters
'regexp/control-character-escape': 'error',
// enforce consistent usage of hexadecimal escape
'regexp/hexadecimal-escape': ['error', 'never'],
// enforce into your favorite case
'regexp/letter-case': ['error', {
caseInsensitive: 'lowercase',
Expand All @@ -459,7 +461,7 @@ const base = {
// disallow duplicate characters in the RegExp character class
'regexp/no-dupe-characters-character-class': 'error',
// disallow duplicate disjunctions
'regexp/no-dupe-disjunctions': 'error',
'regexp/no-dupe-disjunctions': ['error', { report: 'all' }],
// disallow alternatives without elements
'regexp/no-empty-alternative': 'error',
// disallow empty group
Expand All @@ -468,8 +470,6 @@ const base = {
'regexp/no-empty-lookarounds-assertion': 'error',
// disallow escape backspace `([\b])`
'regexp/no-escape-backspace': 'error',
// enforce consistent usage of hexadecimal escape
'regexp/hexadecimal-escape': ['error', 'never'],
// disallow invisible raw character
'regexp/no-invisible-character': 'error',
// disallow lazy quantifiers at the end of an expression
Expand All @@ -486,6 +486,8 @@ const base = {
'regexp/no-optional-assertion': 'error',
// disallow backreferences that reference a group that might not be matched
'regexp/no-potentially-useless-backreference': 'error',
// disallow standalone backslashes
'regexp/no-standalone-backslash': 'error',
// disallow trivially nested assertions
'regexp/no-trivially-nested-assertion': 'error',
// disallow nested quantifiers that can be rewritten as one quantifier
Expand All @@ -510,10 +512,14 @@ const base = {
'regexp/no-useless-non-capturing-group': 'error',
// disallow unnecessary quantifier non-greedy (`?`)
'regexp/no-useless-non-greedy': 'error',
// disallow quantifiers that can be removed
'regexp/no-useless-quantifier': 'error',
// disallow unnecessary range of characters by using a hyphen
'regexp/no-useless-range': 'error',
// disallow unnecessary `{n,m}`` quantifier
'regexp/no-useless-two-nums-quantifier': 'error',
// disallow quantifiers with a maximum of zero
'regexp/no-zero-quantifier': 'error',
// disallow the alternatives of lookarounds that end with a non-constant quantifier
'regexp/optimal-lookaround-quantifier': 'error',
// enforces elements order in character class
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"eslint-plugin-jsonc": "^1.2.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-qunit": "^6.1.0",
"eslint-plugin-regexp": "~0.9.0",
"eslint-plugin-regexp": "~0.10.0",
"eslint-plugin-sonarjs": "~0.7.0",
"eslint-plugin-unicorn": "^31.0.0",
"jsonc-eslint-parser": "^1.0.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/internals/regexp-exec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';
/* eslint-disable regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
/* eslint-disable regexp/no-useless-quantifier -- testing */
var regexpFlags = require('./regexp-flags');
var stickyHelpers = require('./regexp-sticky-helpers');
var shared = require('./shared');
Expand All @@ -19,7 +21,6 @@ var UPDATES_LAST_INDEX_WRONG = (function () {
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;

// nonparticipating capturing group, copied from es5-shim's String#split patch.
// eslint-disable-next-line regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;

var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;
Expand Down
4 changes: 2 additions & 2 deletions tests/compat/tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable radix -- required for testing */
/* eslint-disable radix, regexp/no-assertion-capturing-group, regexp/no-lazy-ends, regexp/no-useless-quantifier -- required for testing */
var GLOBAL = Function('return this')();
var WHITESPACES = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
'\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
Expand Down Expand Up @@ -763,7 +763,7 @@ GLOBAL.tests = {
re1.exec('a');
re2.exec('a');
return re1.lastIndex === 0 && re2.lastIndex === 0
// eslint-disable-next-line regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- required for testing
// eslint-disable-next-line regexp/no-empty-group -- required for testing
&& /()??/.exec('')[1] === undefined
&& reSticky.exec('abc')[0] === 'a'
&& reSticky.exec('abc') === null
Expand Down

0 comments on commit c7170fb

Please sign in to comment.