-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
fix: switch grapheme-splitter
to graphemer
#17160
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
Thanks for the PR @fisker. I can see that the issue in your snippet is affecting the behavior of the For example: /* eslint key-spacing: ["error", { align: "value" }] */
const foo = {
"👍👍👍": 1, // false positive
"👩🦰👩👩👦👦🏳️🌈": 2,
};
const bar = {
"👍👍👍👍": 1,
"👩🦰👩👩👦👦🏳️🌈": 2, // false negative
}; |
lib/shared/string-utils.js
Outdated
if (typeof Intl !== "undefined" && typeof Intl.Segmenter !== "undefined") { | ||
iterateGraphemes = Intl.Segmenter.prototype.segment.bind(new Intl.Segmenter()); | ||
} else { | ||
const Graphemer = require("graphemer").default; | ||
|
||
iterateGraphemes = Graphemer.prototype.iterateGraphemes.bind(new Graphemer()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these two methods always give the same result? If we can't guarantee that, it would be better to switch to just graphemer
now and then just Intl.Segmenter
in the next major version (when we drop Node < 16), because we wouldn't want linting to produce different results in different environments.
getGraphemeCount
grapheme-splitter
to graphemer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Leaving open for others to review, and waiting for #17116 to be closed before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:
Switch
grapheme-splitter
tographemer
.Use
Intl.Segmenter
when available.What changes did you make? (Give an overview)
Is there anything you'd like reviewers to focus on?