Skip to content

Commit 57450cb

Browse files
committed
update eslint-plugin-regexp
1 parent 7414ff1 commit 57450cb

File tree

11 files changed

+20
-16
lines changed

11 files changed

+20
-16
lines changed

.eslintrc.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,22 @@ const base = {
474474
'regexp/match-any': ['error', { allows: ['[\\S\\s]', 'dotAll'] }],
475475
// enforce use of escapes on negation
476476
'regexp/negation': 'error',
477-
// disallow capturing group that captures assertions
478-
'regexp/no-assertion-capturing-group': 'error',
479477
// disallow duplicate characters in the RegExp character class
480478
'regexp/no-dupe-characters-character-class': 'error',
481479
// disallow duplicate disjunctions
482480
'regexp/no-dupe-disjunctions': ['error', { report: 'all' }],
483481
// disallow alternatives without elements
484482
'regexp/no-empty-alternative': 'error',
483+
// disallow capturing group that captures empty
484+
'regexp/no-empty-capturing-group': 'error',
485485
// disallow empty group
486486
'regexp/no-empty-group': 'error',
487487
// disallow empty lookahead assertion or empty lookbehind assertion
488488
'regexp/no-empty-lookarounds-assertion': 'error',
489489
// disallow escape backspace `([\b])`
490490
'regexp/no-escape-backspace': 'error',
491+
// disallow invalid regular expression strings in RegExp constructors
492+
'regexp/no-invalid-regexp': 'error',
491493
// disallow invisible raw character
492494
'regexp/no-invisible-character': 'error',
493495
// disallow lazy quantifiers at the end of an expression
@@ -526,10 +528,10 @@ const base = {
526528
'regexp/no-useless-escape': 'error',
527529
// disallow unnecessary regex flags
528530
'regexp/no-useless-flag': 'error',
531+
// disallow unnecessarily non-greedy quantifiers
532+
'regexp/no-useless-lazy': 'error',
529533
// disallow unnecessary non-capturing group
530534
'regexp/no-useless-non-capturing-group': 'error',
531-
// disallow unnecessary quantifier non-greedy (`?`)
532-
'regexp/no-useless-non-greedy': 'error',
533535
// disallow quantifiers that can be removed
534536
'regexp/no-useless-quantifier': 'error',
535537
// disallow unnecessary range of characters by using a hyphen
@@ -542,8 +544,6 @@ const base = {
542544
'regexp/optimal-quantifier-concatenation': 'error',
543545
// disallow the alternatives of lookarounds that end with a non-constant quantifier
544546
'regexp/optimal-lookaround-quantifier': 'error',
545-
// enforces elements order in character class
546-
'regexp/order-in-character-class': 'error',
547547
// enforce using character class
548548
'regexp/prefer-character-class': 'error',
549549
// enforce using `\d`
@@ -570,6 +570,8 @@ const base = {
570570
'regexp/prefer-w': 'error',
571571
// sort alternatives if order doesn't matter
572572
'regexp/sort-alternatives': 'error',
573+
// enforces elements order in character class
574+
'regexp/sort-character-class-elements': 'error',
573575
// require regex flags to be sorted
574576
'regexp/sort-flags': 'error',
575577
// disallow not strictly valid regular expressions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"eslint-plugin-jsonc": "^1.4.0",
4343
"eslint-plugin-node": "^11.1.0",
4444
"eslint-plugin-qunit": "^6.2.0",
45-
"eslint-plugin-regexp": "~0.13.2",
45+
"eslint-plugin-regexp": "^1.0.0",
4646
"eslint-plugin-sonarjs": "~0.10.0",
4747
"eslint-plugin-unicorn": "^35.0.0",
4848
"jsonc-eslint-parser": "^1.1.0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var userAgent = require('../internals/engine-user-agent');
22
var global = require('../internals/global');
33

4-
module.exports = /iphone|ipod|ipad/i.test(userAgent) && global.Pebble !== undefined;
4+
module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
var userAgent = require('../internals/engine-user-agent');
22

3-
module.exports = /(?:iphone|ipod|ipad).*applewebkit/i.test(userAgent);
3+
module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);

packages/core-js/internals/regexp-exec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
/* eslint-disable regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
2+
/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
33
/* eslint-disable regexp/no-useless-quantifier -- testing */
44
var toString = require('../internals/to-string');
55
var regexpFlags = require('../internals/regexp-flags');

packages/core-js/modules/es.string.replace.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
4141
result.groups = { a: '7' };
4242
return result;
4343
};
44+
// eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
4445
return ''.replace(re, '$<a>') !== '7';
4546
});
4647

packages/core-js/modules/es.string.split.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
3737
'test'.split(/(?:)/, -1).length != 4 ||
3838
'ab'.split(/(?:ab)*/).length != 2 ||
3939
'.'.split(/(.?)(.?)/).length != 4 ||
40-
// eslint-disable-next-line regexp/no-assertion-capturing-group, regexp/no-empty-group -- required for testing
40+
// eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
4141
'.'.split(/()()/).length > 1 ||
4242
''.split(/.?/).length
4343
) {

scripts/check-dependencies.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ await Promise.all((await globby(['package.json', 'packages/*/package.json'])).ma
1313
Object.assign(dependencies, devDependencies);
1414
for (const name of Object.keys(dependencies)) {
1515
const { required, stable, warn } = dependencies[name];
16-
if (/^(?:git|file)/.test(required) || warn || eq(minVersion(required), coerce(stable))) {
16+
if (/^(?:file|git)/.test(required) || warn || eq(minVersion(required), coerce(stable))) {
1717
delete dependencies[name];
1818
}
1919
}

tests/compat/tests.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable radix, regexp/no-assertion-capturing-group, regexp/no-lazy-ends, regexp/no-useless-quantifier -- required for testing */
1+
/* eslint-disable radix, regexp/no-empty-capturing-group, regexp/no-lazy-ends, regexp/no-useless-quantifier -- required for testing */
22
var GLOBAL = Function('return this')();
33
var WHITESPACES = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
44
'\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
@@ -917,6 +917,7 @@ GLOBAL.tests = {
917917

918918
return ''.replace(O) == 7
919919
&& execCalled
920+
// eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
920921
&& ''.replace(re2, '$<a>') === '7'
921922
// eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
922923
&& 'a'.replace(/./, '$0') === '$0'

tests/tests/es.regexp.constructor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* eslint-disable regexp/order-in-character-class, regexp/no-dupe-characters-character-class -- required for testing */
2-
/* eslint-disable regexp/no-useless-character-class, regexp/no-useless-flag, regexp/sort-flags -- required for testing */
1+
/* eslint-disable regexp/no-invalid-regexp, regexp/sort-flags -- required for testing */
2+
/* eslint-disable regexp/no-useless-character-class, regexp/no-useless-flag -- required for testing */
33
import { DESCRIPTORS, GLOBAL } from '../helpers/constants';
44
import { nativeSubclass } from '../helpers/helpers';
55

0 commit comments

Comments
 (0)