+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Conversation

ematipico
Copy link
Contributor

Summary

This PR adds support for checking the presence of spread attributes inside some rules around JSX. The position where the spread attribute is positioned is important. These two snippets yield two different results.

<div {...spread} onClick={}></div>
<div onClick={} {...spread} ></div>

Considering that we don't have any typing information around the spread props, it's safe to assume that when a spread attribute is after the attribute that triggers the rule, the rule should not be triggered anymore, because the spread attribute might contain the correct attribute.

Test Plan

I added new test cases in the rules that have been affected

@ematipico ematipico requested a review from a team October 18, 2022 15:46
@netlify
Copy link

netlify bot commented Oct 18, 2022

Deploy Preview for rometools ready!

Name Link
🔨 Latest commit cceccad
🔍 Latest deploy log https://app.netlify.com/sites/rometools/deploys/6357dc96c64ad30009d22f0e
😎 Deploy Preview https://deploy-preview-3444--rometools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ematipico ematipico force-pushed the feature/spread-props branch from b79a3d0 to 83cd5ee Compare October 18, 2022 16:07
@ematipico ematipico added the A-Linter Area: linter label Oct 18, 2022
@ematipico ematipico temporarily deployed to netlify-playground October 18, 2022 16:07 Inactive
@github-actions
Copy link

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45879 45879 0
Passed 44939 44939 0
Failed 940 940 0
Panics 0 0 0
Coverage 97.95% 97.95% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5946 5946 0
Passed 1621 1621 0
Failed 4325 4325 0
Panics 0 0 0
Coverage 27.26% 27.26% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12395 12395 0
Failed 3862 3862 0
Panics 0 0 0
Coverage 76.24% 76.24% 0.00%

@github-actions
Copy link

github-actions bot commented Oct 18, 2022

@xunilrj
Copy link
Contributor

xunilrj commented Oct 19, 2022

Should this be a rule on itself? "Spread should be at the beginning on JSX bla bla bla".

@ematipico
Copy link
Contributor Author

Should this be a rule on itself? "Spread should be at the beginning on JSX bla bla bla".

I think we had a rule that actually wanted to prevent the use of spread props, but it doesn't play well when using other components (like UI libraries) or library authors. If we had a some type information, we could make it a rule.

@ematipico
Copy link
Contributor Author

@leops @xunilrj It would be great if you could give a look to this PR. This is needed in order to promote certain rules to be stable.

@ematipico ematipico force-pushed the feature/spread-props branch from 2bd5398 to 4ef322c Compare October 21, 2022 15:32
@ematipico ematipico temporarily deployed to netlify-playground October 21, 2022 15:32 Inactive
@ematipico ematipico force-pushed the feature/spread-props branch from 4ef322c to 8d05644 Compare October 21, 2022 15:33
@ematipico ematipico temporarily deployed to netlify-playground October 21, 2022 15:33 Inactive
@ematipico ematipico requested a review from MichaReiser October 21, 2022 15:39
@ematipico ematipico added this to the 10.0.0 milestone Oct 21, 2022
///```
///
/// ```jsx,
/// <div onClick={() => {}} {...spread}></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I get why onClick {...spread} is valid but {...spread} onClick is not, in both case the spread expression may inject an onKey* event we don't know about ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right, good catch

@ematipico ematipico force-pushed the feature/spread-props branch from 8d05644 to 5a708b8 Compare October 25, 2022 08:20
@ematipico ematipico requested a review from leops October 25, 2022 08:20
@ematipico ematipico temporarily deployed to netlify-playground October 25, 2022 08:20 Inactive
@ematipico ematipico force-pushed the feature/spread-props branch from 5a708b8 to cceccad Compare October 25, 2022 12:54
@ematipico ematipico temporarily deployed to netlify-playground October 25, 2022 12:54 Inactive
@ematipico ematipico merged commit ee70ea9 into main Oct 25, 2022
@ematipico ematipico deleted the feature/spread-props branch October 25, 2022 16:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A-Linter Area: linter

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载