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

Codemod scripts for SolidJS JavaScript library

License

NotificationsYou must be signed in to change notification settings

solidjs-community/solid-codemod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solid ARIA

Solid Codemod

Codemod scripts for upgradingSolidJS APIs and code,powered byJSCodeshift.

Usage

npx solid-codemod <transforms> <paths> --write

  • transforms - transforms names
  • paths - directories or files to transform
  • --write or-w - write changes (it defaults to dry run)

NOTES:

  • It doesnt accept or use globs.
  • Manytransforms orpaths can be provided separated by spaces
  • Whenpaths is not provided it runs tests on the selectedtransforms
  • Once its done it will display a greenDONE
  • Transforms should modify code when "reliable possible"

Examples

  • solid-codemod - run all transforms internal tests.
  • solid-codemod solid@v2/jsx-properties-to-attributes - run internaltests for selected transform.
  • solid-codemod solid@v2/jsx-properties-to-attributes . - dry runtransform on current directory.
  • solid-codemod solid@v2/jsx-properties-to-attributes . -w - runtransform on current directory and write changes to files.

Codemod Transforms

solid@v2/jsx-properties-to-attributes

Used to update JSX properties vs attributes, from Solid 1.x to Solid2.x.

  • CamelCase attributes to lowercase on known tags (not in components)
  • Unwrapattr: for known attributes
  • onsubmit="return false" ->attr:onsubmit="return false"
  • Ensureboolean attributes values (for static/conditional values)
  • Ensurepseudo-boolean attributes values (for static/conditionalvalues)
  • Warn of unknown attributes

Warning: Do not use in already established Solid 2.x code as itassumes the code is Solid 1.x. For examplefalse is a valid way toremove an attribute in Solid 2.x, while in Solid 1.x it means to havean attribute with that value.

solid@v2/jsx-classlist-to-class

Used to renameclassList attribute toclasshttps://docs.solidjs.com/concepts/components/class-style

solid@v2/jsx-array-map-to-for

Used to changearray.map into the<For/> Solid componenthttps://docs.solidjs.com/reference/components/for

Writing Transforms

  1. Look at thetransforms folder, duplicate and edit a transform.
  2. Test your transform withsolid-codemod solid@v2/your-transform-name
  3. Add the transform to the readme with a description
  4. May usesrc/transforms/shared.js for shared code

Helpers

Some shared code exits for helping author transforms.

  • src/transforms/shared.js - helpers for parsing and logging changesto console.
  • src/data - data helpers for specific Solid versions

Contributing

We're currently looking for transformations which SolidJS community isinterested in. Please create afeature request orupvote/comment onexisting featurerequests which have the input and outputcode of the transformation you are looking for.

For example, here is a feature request totransformuseState/useEffect of ReactJS to createSignal/onCleanup ofSolidJS for your reference.

TODO

  • transfer npm to the solid project
  • figure out how to autopublish to npm

License

MIT

About

Codemod scripts for SolidJS JavaScript library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp