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

feat(eslint-plugin): [no-misused-spread] add new rule#8509

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

Conversation

StyleShit
Copy link
Contributor

Closes#748

yeonjuan reacted with thumbs up emojiomril1 reacted with hooray emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@StyleShit!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedFeb 19, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit07b69b8
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/66f2f3bfacea6e00091a83c5
😎 Deploy Previewhttps://deploy-preview-8509--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedFeb 19, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit07b69b8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 fromNxCloud.

@codecovCodecov
Copy link

codecovbot commentedFeb 19, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.27%. Comparing base(896c731) to head(ab20e73).
Report is 239 commits behind head on main.

Current headab20e73 differs from pull request most recent head07b69b8

Pleaseupload reports for the commit07b69b8 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #8509      +/-   ##==========================================- Coverage   88.73%   87.27%   -1.47%==========================================  Files         426      252     -174       Lines       14881    12363    -2518       Branches     4327     3899     -428     ==========================================- Hits        13205    10790    -2415+ Misses       1534     1303     -231- Partials      142      270     +128
FlagCoverage Δ
unittest87.27% <100.00%> (-1.47%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

Files with missing linesCoverage Δ
...kages/eslint-plugin/src/rules/no-misused-spread.ts100.00% <100.00%> (ø)

... and411 files with indirect coverage changes

@StyleShit
Copy link
ContributorAuthor

Not sure why the tests are failing, seems to pass locally

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Very clean! I like this a lot. Just a few touchup requests. ✨

Eevee Pokemon happily looking at sparkles, with sparkly eyes

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelFeb 23, 2024
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelFeb 27, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Progress! 🚀

Sorry, I'm only now realizing the class instance stuff might need an option. I think I've look at this PR too much - we should get someone else from @typescript-eslint/triage-team to look too. 😅

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelMar 5, 2024
@JoshuaKGoldbergJoshuaKGoldberg requested a review froma teamMarch 5, 2024 17:39
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelMar 5, 2024
@auvredauvred added the awaiting responseIssues waiting for a reply from the OP or another party labelMar 7, 2024
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelSep 10, 2024
@@ -5,7 +5,7 @@
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"lib": ["es2015", "es2017", "esnext"],
"lib": ["es2015", "es2017", "esnext", "DOM"],
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

this fixes theHTMLElement tests

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it needs further clarification from#9648

Choose a reason for hiding this comment

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

Looks like this caught an existing violation in our codebase:

/home/runner/work/typescript-eslint/typescript-eslint/packages/website/src/theme/NotFound/Content/index.tsx  16:17  error  Using the spread operator on a string can cause unexpected behavior. Prefer `String.split('')` instead  @typescript-eslint/no-misused-spread

yarn lint on the repository will need to pass.

(posting this comment here because GitHub won't let me post on an unchanged file)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

haha, seems like we have conflicting rules here 😅

image

image

Choose a reason for hiding this comment

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

lol. cc@abrahamguo@kirkwaiblinger from#9834 - looks like this just blatantly disagrees withsindresorhus/eslint-plugin-unicorn#1489 ->https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-spread.md.

Maybe we should just not go for strings at all to start? Seems like maybe it's use-case specific?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't have any strong opinion for either of the sides, so... 🤷‍♂️

(it's also more of a style thing rather than something that could cause errors, no?)

any objection to removing it@abrahamguo@kirkwaiblinger?

Copy link
Member

Choose a reason for hiding this comment

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

Here are my suggestions.

  1. Never ever usesplit(""). It doesn't do what you think it does for many scripts.
  2. [...str] is fineby principle but may still be surprising and not have the intended behavior, especially for emojis. In fact TC39 now considers strings being iterable as a mistake and all future built-in APIs that accept iterables will reject strings by default. If you really want to spread strings, either disable this rule or useIterator.from, or think about alternatives such asIntl.Segmenter.
  3. An option to allow it is good enough. We can consider changing the default totrue, but my vote is to be strict by default.

Choose a reason for hiding this comment

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

+1 from me to everything Josh has indicated. I think this is a really interesting case of the language going one direction (... iterable strings), lint rules following that direction, then the language realizing the direction being wrong. If other lint rules are asking to use... on strings then we should file an issue on them saying they should update.

Copy link
Contributor

@abrahamguoabrahamguoOct 8, 2024
edited
Loading

Choose a reason for hiding this comment

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

@JoshuaKGoldberg Sure. However, if you are choosing betweenstr.split('') vs[...str], don't you agree that[...str] is certainly more correct thanstr.split(''), sincestr.split('') will break surrogate pairs?

and therefore, the premise ofunicorn/prefer-spread is correct, even if[...str] might not be thebest choice?

Choose a reason for hiding this comment

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

To be honest, I'm coming back from a couple of weeks of intense conference organizing, and don't have the headspace to re-think this deeply right now. I trust@Josh-Cena's opinion on things. 😄

Copy link
Member

Choose a reason for hiding this comment

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

Bothsplit("") and... are only correct under certain assumptions, and practically, most of the time, the former is not much more wrong than the latter. It's fine for unicorn to recommend spreading since it's nominally safer, and if users accept safety at the level of spreading they are free to configure the allow config, but banning it by default exposes such unsafety.

Choose a reason for hiding this comment

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

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Awesome!! I think the only blocker from me is fixing existing violations from this repo.

I took the liberty of merging the latestmain in to fix the unrelated CI failures.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelSep 13, 2024
@StyleShit
Copy link
ContributorAuthor

StyleShit commentedSep 13, 2024
edited
Loading

Awesome!! I think the only blocker from me is fixing existing violations from this repo.

@JoshuaKGoldberg

Seems like my most important comment here is hidden, so I'm assuming you haven't seen it 😅
#8509 (comment)

The tests will still fail 😞

JoshuaKGoldberg reacted with thumbs up emoji

@StyleShit
Copy link
ContributorAuthor

@JoshuaKGoldberg
Continuingthis thread here, so it'll be easier for you to follow:

builtinSymbolLikes.ts and isSymbolFromDefaultLibrary.ts

Seems like both of them don't follow the references/aliases ofWeakRef. When I try to check forisBuiltinSymbolLike(program, type, 'WeakRefConstructor') on aWeakRef, I getfalse, becauseWeakRef doesn't extendWeakRefConstructor, but references to it:
https://github.com/microsoft/TypeScript/blob/48f0b3cc383bfd6337fc9b5a0afdc1642473a57d/src/lib/es2021.weakref.d.ts#L23

Anyway... Solved with a list of builtins (I don't like it, but I have no other idea at this point 😞)

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelSep 24, 2024
@kirkwaiblingerkirkwaiblinger added the awaiting responseIssues waiting for a reply from the OP or another party labelOct 9, 2024
@Josh-Cena
Copy link
Member

Hi@StyleShit do you think you could find some time recently to finish it? Otherwise we could also take it on since there isn't a lot left

@StyleShit
Copy link
ContributorAuthor

Hi@StyleShit do you think you could find some time recently to finish it? Otherwise we could also take it on since there isn't a lot left

@Josh-Cena

I'm currently on reserve duty so I don't know whether I'll have time in the near future 😓
If you have some time to finish this PR, that would be great!
(honestly, I don't remember how much work is left here)

Thank you! 🙏

omril1 reacted with heart emoji

@JoshuaKGoldberg
Copy link
Member

From#8443 (comment):

Cool! I'd really like to get this one and#8509 in by the end of the year, they're great rules to have that I've wanted for a while. So let's timebox these two to, say, the end of the month. If you don't end up having time by then, no worries, one of us on the team can send in a PR with the same commit history & a co-author attribution.

Good luck + best wishes on reserve duty. ❤️

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 3, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@abrahamguoabrahamguoabrahamguo left review comments

@omril1omril1omril1 left review comments

@Josh-CenaJosh-CenaJosh-Cena left review comments

@auvredauvredauvred requested changes

@bradzacherbradzacherbradzacher left review comments

@JoshuaKGoldbergJoshuaKGoldbergAwaiting requested review from JoshuaKGoldberg

Assignees
No one assigned
Labels
awaiting responseIssues waiting for a reply from the OP or another partyenhancement: new plugin ruleNew rule request for eslint-plugin
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Rule proposal: prevent array, iterable and function spreads into objects
8 participants
@StyleShit@JoshuaKGoldberg@Josh-Cena@bradzacher@abrahamguo@omril1@auvred@kirkwaiblinger

[8]ページ先頭

©2009-2025 Movatter.jp