Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): [no-misused-spread] correct and elaborate string spread report message#10751

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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
9 changes: 7 additions & 2 deletionspackages/eslint-plugin/src/rules/no-misused-spread.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,8 +57,13 @@ export default createRule<Options, MessageIds>({
'Using the spread operator on a Map in an object will result in an empty object. Did you mean to use `Object.fromEntries(map)` instead?',
noPromiseSpreadInObject:
'Using the spread operator on Promise in an object can cause unexpected behavior. Did you forget to await the promise?',
noStringSpread:
"Using the spread operator on a string can cause unexpected behavior. Prefer `.split('')` instead.",
noStringSpread: [
'Using the spread operator on a string can mishandle special characters, as can `.split("")`.',
'- `...` produces Unicode code points, which will decompose complex emojis into individual emojis',
'- .split("") produces UTF-16 code units, which breaks rich characters in many languages',
'Consider using `Intl.Segmenter` for locale-aware string decomposition.',
"Otherwise, if you don't need to preserve emojis or other non-Ascii characters, disable this lint rule on this line or configure the 'allow' rule option.",
].join('\n'),
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

To anybody with opinions on string splitting: please bikeshed theheck out of this message!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!
I would prefer having the disable comment sentence as the otherwise with something like

  • If you want to split on graphemes, consider usingIntl.Segmenter
  • Otherwise, if this string does not need to preserve emojis ...

kirkwaiblinger reacted with thumbs up emoji

Choose a reason for hiding this comment

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

+1. I think it makes sense to say "consider using Intl.Segmenter for robust, locale-aware string decomposition." first, and then "Otherwise, if you don't need to preserve emojis or other non-Ascii characters, disable, etc..."

ArnaudBarre reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

the people have spoken

kirkwaiblinger reacted with laugh emoji
},
schema: [
{
Expand Down
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp