Add sx support to no-conflicting-props eslint rule#1705
Conversation
|
Hi @mjames-c! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
sx support to no-conflicting-props eslint rule
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the stylex-no-conflicting-props ESLint rule to flag className/style conflicts not only with stylex.props() spreads, but also with a configurable StyleX “shorthand” prop (default: sx) on host elements.
Changes:
- Add detection for a shorthand StyleX prop (default
sx) on lowercase JSX host elements and report conflictingclassName/style. - Introduce an
sxPropNameoption (string orfalse) and tailor report messages based on whether the conflict comes fromstylex.props()or shorthand usage. - Extend unit tests to cover shorthand behavior and configuration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/@stylexjs/eslint-plugin/src/stylex-no-conflicting-props.js | Adds shorthand-prop detection, new option schema, and message selection logic. |
| packages/@stylexjs/eslint-plugin/tests/stylex-no-conflicting-props-test.js | Adds valid/invalid cases for shorthand prop conflicts and configuration. |
| function isLowercaseHostElement(node: JSXOpeningElement): boolean { | ||
| return ( | ||
| node.name.type === 'JSXIdentifier' && | ||
| typeof node.name.name === 'string' && | ||
| node.name.name[0] === node.name.name[0].toLowerCase() | ||
| ); | ||
| } |
There was a problem hiding this comment.
this matches the logic in the babel transformer:
stylex/packages/@stylexjs/babel-plugin/src/index.js
Lines 313 to 315 in 20ce0b6
e641a81 to
fe600b1
Compare
my company (Canva) does have a CLA with Meta but I'm waiting to be added to the list of contributors (hopefully by end of week) |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
What changed / motivation ?
sxandclassNameshould not be used together (similar to...stylex.props(...))Linked PR/Issues
Fixes #1359
Pre-flight checklist
Contribution Guidelines