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

feat: replace dependency graphemer with Intl.Segmenter #18110

Merged
merged 1 commit into from Apr 19, 2024
Merged

Conversation

fasttime
Copy link
Member

@fasttime fasttime commented Feb 10, 2024

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: replace a dependency with a native implementation.

See the discussion in #17835

Fixes #17835

What changes did you make? (Give an overview)

Replaced graphemer with the native Segments implementation provided by Intl.Segmenter.

Is there anything you'd like reviewers to focus on?

  • The implementations are not 100% equivalent
  • The Segments behavior with respect to which sequences are considered graphemes is expected to change with newer version of Unicode
  • Graphemer is currently used in the rules id-length and key-spacing
  • As of today, the Segments API is not supported in all browsers: https://caniuse.com/?search=Segments

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Feb 10, 2024
Copy link

netlify bot commented Feb 10, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 7264835
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/662165e29278460008dc6cc6

Copy link

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@fasttime
Copy link
Member Author

This is currently blocked on Firefox not supporting Intl.Segmenter in release builds: https://bugzilla.mozilla.org/show_bug.cgi?id=1423593#c58.

@fasttime fasttime added blocked This change can't be completed until another issue is resolved and removed Stale labels Feb 23, 2024
@fasttime fasttime self-assigned this Mar 4, 2024
@aladdin-add
Copy link
Member

it's supported on node.js >= 16, so it seems not a blocker:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#browser_compatibility

re Firefox, can we add a polyfill in the playground?

@fasttime
Copy link
Member Author

it's supported on node.js >= 16, so it seems not a blocker: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#browser_compatibility

I can't say if it's acceptable for ESLint to have a core rule that works in Node.js but not in (all major) browsers. The Linter API is intended to work also outside of Node.js, but the same may not apply to individual rules, so maybe it's okay.

re Firefox, can we add a polyfill in the playground?

graphemer is likely the best polyfill these days.

@aladdin-add
Copy link
Member

Currently eslint doesn't officially support browsers, so I think that's acceptable. thoughts? @nzakas @mdjermanovic

@nzakas
Copy link
Member

nzakas commented Apr 1, 2024

The purpose of this effort was to remove graphemer as a dependency. If we need to include it as a polyfill, then we're not really getting any benefit.

@aladdin-add
Copy link
Member

aladdin-add commented Apr 3, 2024

@nzakas seems we are not on the same page. It will remove graphemer from eslint's dependencies, and add the polyfill in our website(playground).

@nzakas
Copy link
Member

nzakas commented Apr 3, 2024

Ah, I see, thanks for explaining. In that case, I'm 👍

@fasttime
Copy link
Member Author

Intl.Segmenter is available in new Firefox 125.

@fasttime fasttime removed the blocked This change can't be completed until another issue is resolved label Apr 18, 2024
@fasttime fasttime marked this pull request as ready for review April 18, 2024 18:34
@fasttime fasttime requested a review from a team as a code owner April 18, 2024 18:34
@nzakas
Copy link
Member

nzakas commented Apr 18, 2024

Release notes for Firefox 125: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/125

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Looks like all tests are passing, so I think we're good to go.

@nzakas
Copy link
Member

nzakas commented Apr 18, 2024

Would like an approval from @aladdin-add based on previous comments before merging.

Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

Thank you 🎉

@aladdin-add aladdin-add added the accepted There is consensus among the team that this change meets the criteria for inclusion label Apr 19, 2024
@aladdin-add aladdin-add merged commit 751b518 into main Apr 19, 2024
18 checks passed
@aladdin-add aladdin-add deleted the use-segmenter branch April 19, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Change Request: Replace graphemer with Intl.Segmenter
4 participants