1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 15:47:57 +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:
Jonas Jenwald 2023-03-23 12:34:08 +01:00
parent 5f64621d46
commit 1fc09f0235
26 changed files with 58 additions and 56 deletions

View file

@ -903,7 +903,7 @@ function createPostTable(properties) {
function createPostscriptName(name) {
// See https://docs.microsoft.com/en-us/typography/opentype/spec/recom#name.
return name.replace(/[^\x21-\x7E]|[[\](){}<>/%]/g, "").slice(0, 63);
return name.replaceAll(/[^\x21-\x7E]|[[\](){}<>/%]/g, "").slice(0, 63);
}
function createNameTable(name, proto) {
@ -994,7 +994,7 @@ class Font {
// Fallback to checking the font name, in order to improve text-selection,
// since the /Flags-entry is often wrong (fixes issue13845.pdf).
if (!isSerifFont && !properties.isSimulatedFlags) {
const baseName = name.replace(/[,_]/g, "-").split("-")[0],
const baseName = name.replaceAll(/[,_]/g, "-").split("-")[0],
serifFonts = getSerifFonts();
for (const namePart of baseName.split("+")) {
if (serifFonts[namePart]) {
@ -1445,7 +1445,7 @@ class Font {
for (let j = 0, jj = nameTable.length; j < jj; j++) {
for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
const nameEntry =
nameTable[j][k] && nameTable[j][k].replace(/\s/g, "");
nameTable[j][k] && nameTable[j][k].replaceAll(/\s/g, "");
if (!nameEntry) {
continue;
}