mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Enable the unicorn/prefer-string-replace-all
ESLint plugin rule
Note that the `replaceAll` method still requires that a *global* regular expression is used, however by using this method it's immediately obvious when looking at the code that all occurrences will be replaced; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#parameters Please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
This commit is contained in:
parent
5f64621d46
commit
1fc09f0235
26 changed files with 58 additions and 56 deletions
|
@ -117,7 +117,7 @@ function formatL10nValue(text, args) {
|
|||
if (!args) {
|
||||
return text;
|
||||
}
|
||||
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
|
||||
return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
|
||||
return name in args ? args[name] : "{{" + name + "}}";
|
||||
});
|
||||
}
|
||||
|
|
|
@ -663,7 +663,7 @@ class PDFFindController {
|
|||
#convertToRegExpString(query, hasDiacritics) {
|
||||
const { matchDiacritics } = this._state;
|
||||
let isUnicode = false;
|
||||
query = query.replace(
|
||||
query = query.replaceAll(
|
||||
SPECIAL_CHARS_REG_EXP,
|
||||
(
|
||||
match,
|
||||
|
|
|
@ -223,7 +223,7 @@ function removeNullCharacters(str, replaceInvisible = false) {
|
|||
return str;
|
||||
}
|
||||
if (replaceInvisible) {
|
||||
str = str.replace(InvisibleCharactersRegExp, " ");
|
||||
str = str.replaceAll(InvisibleCharactersRegExp, " ");
|
||||
}
|
||||
return str.replaceAll("\x00", "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue