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

ESLint and Biome fixes #148

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

ESLint and Biome fixes #148

wants to merge 2 commits into from

Conversation

tdulcet
Copy link
Contributor

@tdulcet tdulcet commented Dec 11, 2024

  • Minor ESLint and Biome fixes.
    • Removed use of the typeof operator.
    • Replaced usages of window with globalThis.
    • Switched twisted if/else and ternary statements.
  • Updated to use Intl.Segmenter.
    • Requires Firefox/Thunderbird 125 or greater.
  • Updated to optionally use RegExp.escape if available.
    • Requires Firefox/Thunderbird 134.

src/background/modules/ContextMenu.js Show resolved Hide resolved
src/common/modules/AutocorrectHandler.js Outdated Show resolved Hide resolved
}

return count;
return Array.from(segmenter.segment(str.replaceAll("\u200D", ""))).length;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
return Array.from(segmenter.segment(str.replaceAll("\u200D", ""))).length;
const STRING_JOINER_CHAR = "\u200D"
return Array.from(segmenter.segment(str.replaceAll(STRING_JOINER_CHAR, ""))).length;

Another example on how you can remove the explanatory comment above and explain the code… with code itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my comment in Unicodify: rugk/unicodify#96 (comment)

@@ -125,6 +123,8 @@ export async function triggerOnSelect(emoji) {
if (closePopup) {
window.close();
}
} else {
CommonMessages.showError("couldNotDoAction", true);
Copy link
Owner

Choose a reason for hiding this comment

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

I am unsure, is couldNotDoAction really already defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above on lines 117-119. This is just switching the twisted if/else statements per the no-negated-condition ESLint rule. The Unicorn ESLint plugin includes an autofix for this.

@tdulcet tdulcet requested a review from rugk December 19, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants