Skip to content

feat: new lint rule to enforce stylex file extension - #704

Merged
nmn merged 2 commits into
mainfrom
enforce-stylex-extension
Oct 2, 2024
Merged

nmn merged 2 commits into
mainfrom
enforce-stylex-extension

Conversation

@mellyeliu

@mellyeliu mellyeliu commented Oct 1, 2024 •

Copy link
Copy Markdown
Member

Context

This ESLint rule ensures consistency in file naming conventions when exporting stylex.defineVars.

Specifically:

  • Files that export stylex.defineVars must end with .stylex.jsx or .stylex.tsx
  • Files that do not export stylex.defineVars must not use the .stylex.jsx or .stylex.tsx extensions
  • Users can configure the file extension via a themeFileExtension option (e.g., .custom.jsx), defaulting to .stylex.jsx.

Test Cases:

Valid cases:

  • Files with stylex.defineVars export correctly using .stylex.jsx, .stylex.tsx, or custom extensions.
  • Files without stylex.defineVars export using non-.stylex extensions.

Invalid cases:

  • Files exporting stylex.defineVars without the correct extension.

  • Files not exporting stylex.defineVars but using .stylex.jsx/.tsx or custom extensions incorrectly.

  • I have read the contributing guidelines
    Contribution Guidelines

  • Performed a self-review of my code

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 1, 2024
@mellyeliu
mellyeliu force-pushed the enforce-stylex-extension branch 2 times, most recently from 0786e46 to 3f44a85 Compare October 1, 2024 07:21
@mellyeliu
mellyeliu force-pushed the enforce-stylex-extension branch from 3f44a85 to 5c25d14 Compare October 1, 2024 07:45
@github-actions

github-actions Bot commented Oct 1, 2024 •

Copy link
Copy Markdown

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

@stylexjs/scripts@0.7.5 size:compare
./size-compare.js /tmp/tmp.GDfm07pnHX /tmp/tmp.ZNO4VdWUV0

Results Base Patch Ratio
stylex/lib/stylex.js
· compressed 899 899 1.00
· minified 3,223 3,223 1.00
stylex/lib/StyleXSheet.js
· compressed 1,266 1,266 1.00
· minified 3,776 3,776 1.00
rollup-example/.build/bundle.js
· compressed 563,484 563,484 1.00
· minified 10,185,368 10,185,368 1.00
rollup-example/.build/stylex.css
· compressed 99,154 99,154 1.00
· minified 745,649 745,649 1.00

@nmn nmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not quite what we want.

@nmn nmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You missed Default Exports. Default exports should be treated all other exports.

@mellyeliu

Copy link
Copy Markdown
Member Author

Processing for default exports, general refactor to shared functions

@mellyeliu
mellyeliu force-pushed the enforce-stylex-extension branch from 249598d to b27a597 Compare October 2, 2024 00:08

@nmn nmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice big improvement. Thanks!

This branch was successfully deployed

1 active deployment
Preview — b27a5979 Deployed Oct 2, 2024 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants