Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the unicorn/prefer-regexp-test ESLint plugin rule #15460

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/xfa/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripting_api/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/resources/reftest-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Comment on lines +217 to +219
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that changing the regular expression functions also triggered this rule.

random: random === "(EXPECTED RANDOM)",
skip: extra === " (SKIP)",
url,
Expand Down