idea-kotlin-react icon indicating copy to clipboard operation
idea-kotlin-react copied to clipboard

Kotlin React Idea plugin

Kotlin React Tools

Can I use it?

Not yet.

Installation & Usage

Currently the plugin is compatible only with latest dev builds of IntelliJ IDEA and Kotlin. So, at at the moment you should build it yourself: clone this repo and call ./gradlew runIde.

See CONTRIBUTING.md for more details.

Features

Click at Arrow to see the GIF.

Generating React Components boilerplate (generating `RProps interface`, builder function and render function)

creating component

Updating DSL builder function on editing `RProps` declarations

Plugin gracefully updates DSL builder function regardless of changes: adding, renaming and changing type. Properties order are preserved. Even arbitrary builder function code supported.

editing-rprops

All `RBuilder.child(C::class) { ... }` calls are analyzed for missed `RProps` assignments:

2018-03-22 12 35 10

Creating and inspecting `RState` initialization:

04-creating-rstate

Removing/creating `RProps`/`RState`:

05-remove-create-rprops-rstate

Insepctions

RBuilder.child(C::class) { /* lambda */ } calls:

  • [x] Component builder function should be named as "..."
  • [x] Children is not initialized in component builder function
  • [x] Builder function has outdated parameter type
  • [x] Children is used in component, but not initialized
  • [x] All RProps vars should be initialized
  • [x] Builder function contains outdated assignments

RComponent class declaration:

  • [x] Props not passed to constructor
  • [x] Missed builder function
  • [x] Outdated builder function
  • [x] Both "State.init" and "State.init(props)" is overridden
  • [x] Component has state that should be initialized
  • [x] All RState vars should be initialized
  • [x] override fun State.init(props): RProps is not passed to component constructor
  • [x] on children() call: Children is not initialized in component builder function

RProps/RState interface declaration:

  • [x] Only var properties are allowed in RProps/RState interfaces
  • [x] There are no props in RProps/RState interface
  • [x] Value is not initialized in component builder function
  • [x] Builder function contains outdated assignments
  • [x] Builder function contains outdated parameter type
  • [x] Value is not initialized in component state init function

Intentions and Quick fixes

RComponent class declaration:

  • [x] Generate Component builder function
  • [x] Actualize React Component builder function
  • [x] Add props constructor parameter
  • [ ] Initialize RState from RProps
  • [ ] Create RProps for uninitialized RState

RProps/RState interface declaration:

  • [x] Delete empty RProps/RState interface
  • [x] Create RProps/RState
  • [x] Delete RProps/RState property
  • [x] Change val to var

Code completion

  • [x] On typing RComponent super class name: create RComponent boilerplate
    • RProps interface
    • Builder function
    • override render function
  • [ ] On typing class MyComponent(props: ...: suggest ...: MyComponentProps): RComponent<MyComponentProps, RState> { ... }

Creating from usages

  • [ ] RProp property
  • [ ] RState property
  • [ ] RComponent

Refactorings

  • [ ] Change RComponent signature (RProps)
  • [ ] Extract RComponent
  • [ ] Inline RComponent

Actions

  • [ ] Project wizard
  • [ ] HTML to Kotlin React code
  • [ ] RComponent browser preview
  • [ ] Surround with / Unwrap/remove RComponent

Other

  • [ ] RComponent/RProps/RState/builder function gutter icons and navigation
  • [ ] Builder function folding
  • [ ] Emmet

File & Live templates

  • [ ] rcomponent: RComponent file & live template
  • [ ] render: function with RBuilder receiver

Known bugs

  • [ ] Exception on generating RComponent boilerplate
  • [ ] RComponent boilerplate formatting
  • [ ] RState properties warnings not updated when typing in state init function
  • [ ] RProps type is not updated on RProps creating/removing
  • [ ] Multiple warnings on each RProp properties in case of multiple builder functions

Limitions

  • [ ] Detect leaking attrs
  • [ ] Detect leaking this in state init functions
  • [ ] Analyze receiver data flow
    • [ ] Support this.attrs.xxx
    • [ ] Support this.xxx in state init functions
    • [ ] Support assignment to an arbitrary variable
  • [ ] Detect missing body() call
  • [ ] Support inherited components
  • [ ] Support multiple builder functions
  • [ ] Detect children() calls in component render functions