Skip to content

Commit 50133b0

Browse files
authored
Add eslint-plugin-regexp (#24361)
Add [`eslint-plugin-regexp`](https://github.com/ota-meshi/eslint-plugin-regexp) and fix discovered issues. Config is mostly the recommended one, but I relaxed a few rules.
1 parent cf465b4 commit 50133b0

File tree

6 files changed

+160
-4
lines changed

6 files changed

+160
-4
lines changed

.eslintrc.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ plugins:
1515
- eslint-plugin-no-jquery
1616
- eslint-plugin-sonarjs
1717
- eslint-plugin-custom-elements
18+
- eslint-plugin-regexp
1819

1920
env:
2021
es2022: true
@@ -472,6 +473,80 @@ rules:
472473
quote-props: [0]
473474
quotes: [2, single, {avoidEscape: true, allowTemplateLiterals: true}]
474475
radix: [2, as-needed]
476+
regexp/confusing-quantifier: [2]
477+
regexp/control-character-escape: [2]
478+
regexp/hexadecimal-escape: [0]
479+
regexp/letter-case: [0]
480+
regexp/match-any: [2]
481+
regexp/negation: [2]
482+
regexp/no-contradiction-with-assertion: [0]
483+
regexp/no-control-character: [0]
484+
regexp/no-dupe-characters-character-class: [2]
485+
regexp/no-dupe-disjunctions: [2]
486+
regexp/no-empty-alternative: [2]
487+
regexp/no-empty-capturing-group: [2]
488+
regexp/no-empty-character-class: [0]
489+
regexp/no-empty-group: [2]
490+
regexp/no-empty-lookarounds-assertion: [2]
491+
regexp/no-escape-backspace: [2]
492+
regexp/no-extra-lookaround-assertions: [0]
493+
regexp/no-invalid-regexp: [2]
494+
regexp/no-invisible-character: [2]
495+
regexp/no-lazy-ends: [2]
496+
regexp/no-legacy-features: [2]
497+
regexp/no-misleading-capturing-group: [0]
498+
regexp/no-misleading-unicode-character: [0]
499+
regexp/no-missing-g-flag: [2]
500+
regexp/no-non-standard-flag: [2]
501+
regexp/no-obscure-range: [2]
502+
regexp/no-octal: [2]
503+
regexp/no-optional-assertion: [2]
504+
regexp/no-potentially-useless-backreference: [2]
505+
regexp/no-standalone-backslash: [2]
506+
regexp/no-super-linear-backtracking: [0]
507+
regexp/no-super-linear-move: [0]
508+
regexp/no-trivially-nested-assertion: [2]
509+
regexp/no-trivially-nested-quantifier: [2]
510+
regexp/no-unused-capturing-group: [0]
511+
regexp/no-useless-assertions: [2]
512+
regexp/no-useless-backreference: [2]
513+
regexp/no-useless-character-class: [2]
514+
regexp/no-useless-dollar-replacements: [2]
515+
regexp/no-useless-escape: [2]
516+
regexp/no-useless-flag: [2]
517+
regexp/no-useless-lazy: [2]
518+
regexp/no-useless-non-capturing-group: [2]
519+
regexp/no-useless-quantifier: [2]
520+
regexp/no-useless-range: [2]
521+
regexp/no-useless-two-nums-quantifier: [2]
522+
regexp/no-zero-quantifier: [2]
523+
regexp/optimal-lookaround-quantifier: [2]
524+
regexp/optimal-quantifier-concatenation: [0]
525+
regexp/prefer-character-class: [0]
526+
regexp/prefer-d: [0]
527+
regexp/prefer-escape-replacement-dollar-char: [0]
528+
regexp/prefer-lookaround: [0]
529+
regexp/prefer-named-backreference: [0]
530+
regexp/prefer-named-capture-group: [0]
531+
regexp/prefer-named-replacement: [0]
532+
regexp/prefer-plus-quantifier: [2]
533+
regexp/prefer-predefined-assertion: [2]
534+
regexp/prefer-quantifier: [0]
535+
regexp/prefer-question-quantifier: [2]
536+
regexp/prefer-range: [2]
537+
regexp/prefer-regexp-exec: [2]
538+
regexp/prefer-regexp-test: [2]
539+
regexp/prefer-result-array-groups: [0]
540+
regexp/prefer-star-quantifier: [2]
541+
regexp/prefer-unicode-codepoint-escapes: [2]
542+
regexp/prefer-w: [0]
543+
regexp/require-unicode-regexp: [0]
544+
regexp/sort-alternatives: [0]
545+
regexp/sort-character-class-elements: [0]
546+
regexp/sort-flags: [0]
547+
regexp/strict: [2]
548+
regexp/unicode-escape: [0]
549+
regexp/use-ignore-case: [0]
475550
require-atomic-updates: [0]
476551
require-await: [0]
477552
require-unicode-regexp: [0]

docs/assets/js/search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ function populateResults(result) {
138138

139139
function render(templateString, data) {
140140
let conditionalMatches, copy;
141-
const conditionalPattern = /\$\{\s*isset ([a-zA-Z]*) \s*\}(.*)\$\{\s*end\s*}/g;
142-
// since loop below depends on re.lastInxdex, we use a copy to capture any manipulations whilst inside the loop
141+
const conditionalPattern = /\$\{\s*isset ([a-zA-Z]*) \s*\}(.*)\$\{\s*end\s*\}/g;
142+
// since loop below depends on re.lastIndex, we use a copy to capture any manipulations whilst inside the loop
143143
copy = templateString;
144144
while ((conditionalMatches = conditionalPattern.exec(templateString)) !== null) {
145145
if (data[conditionalMatches[1]]) {

package-lock.json

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"eslint-plugin-import": "2.27.5",
6666
"eslint-plugin-jquery": "1.5.1",
6767
"eslint-plugin-no-jquery": "2.7.0",
68+
"eslint-plugin-regexp": "1.14.0",
6869
"eslint-plugin-sonarjs": "0.19.0",
6970
"eslint-plugin-unicorn": "46.0.0",
7071
"eslint-plugin-vue": "9.11.0",

web_src/js/features/codeeditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function togglePreviewDisplay(previewable) {
136136
if (!previewTab) return;
137137

138138
if (previewable) {
139-
const newUrl = (previewTab.getAttribute('data-url') || '').replace(/(.*)\/.*/i, `$1/markup`);
139+
const newUrl = (previewTab.getAttribute('data-url') || '').replace(/(.*)\/.*/, `$1/markup`);
140140
previewTab.setAttribute('data-url', newUrl);
141141
previewTab.style.display = '';
142142
} else {

web_src/js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function isDarkTheme() {
3232

3333
// strip <tags> from a string
3434
export function stripTags(text) {
35-
return text.replace(/<[^>]*>?/gm, '');
35+
return text.replace(/<[^>]*>?/g, '');
3636
}
3737

3838
// searches the inclusive range [minValue, maxValue].

0 commit comments

Comments
 (0)