diff --git a/.eslintrc b/.eslintrc index 979e2156a..15a47c299 100644 --- a/.eslintrc +++ b/.eslintrc @@ -59,6 +59,7 @@ "unicorn/prefer-dom-node-remove": "error", "unicorn/prefer-logical-operator-over-ternary": "error", "unicorn/prefer-modern-dom-apis": "error", + "unicorn/prefer-regexp-test": "error", "unicorn/prefer-string-starts-ends-with": "error", // Possible errors diff --git a/src/core/xfa/config.js b/src/core/xfa/config.js index f82e79ea6..75e55f8ec 100644 --- a/src/core/xfa/config.js +++ b/src/core/xfa/config.js @@ -1005,7 +1005,7 @@ class Rename extends ContentObject { // is no colon. if ( this[$content].toLowerCase().startsWith("xml") || - this[$content].match(new RegExp("[\\p{L}_][\\p{L}\\d._\\p{M}-]*", "u")) + new RegExp("[\\p{L}_][\\p{L}\\d._\\p{M}-]*", "u").test(this[$content]) ) { warn("XFA - Rename: invalid XFA name"); } diff --git a/src/scripting_api/doc.js b/src/scripting_api/doc.js index 42b42dd3a..bfd0968d5 100644 --- a/src/scripting_api/doc.js +++ b/src/scripting_api/doc.js @@ -876,7 +876,7 @@ class Doc extends PDFObject { for (const [name, field] of this._fields.entries()) { if (name.startsWith(fieldName)) { const finalPart = name.slice(len); - if (finalPart.match(pattern)) { + if (pattern.test(finalPart)) { children.push(field); } } diff --git a/test/resources/reftest-analyzer.js b/test/resources/reftest-analyzer.js index e8bf06573..3972c1d37 100644 --- a/test/resources/reftest-analyzer.js +++ b/test/resources/reftest-analyzer.js @@ -214,9 +214,9 @@ window.onload = function () { const extra = match[4]; gTestItems.push({ - pass: !state.match(/FAIL$/), + pass: !state.endsWith("FAIL"), // only one of the following three should ever be true - unexpected: !!state.match(/^TEST-UNEXPECTED/), + unexpected: state.startsWith("TEST-UNEXPECTED"), random: random === "(EXPECTED RANDOM)", skip: extra === " (SKIP)", url,