marcoroth/stimulus-lsp

Code Action: Accept "Did you mean" suggestions for `stimulus.controller.action.invalid` diagnostic

Closed this issue · 1 comments

The stimulus.controller.action.invalid diagnostic message shows you a "Did you mean" message. But, we don't provide a code action to accept that suggestion.

Given this controller:

// app/javascript/controllers/hello_controller.js

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  update() {

  }
}

And this HTML, you would get this diagnostic:

<button data-controller="hello" data-action="click->hello#greet">
<!--                                                      ^^^^^
┌────────────────────────────────────────────────────────────────────────────────────────────┐
│ "greet" isn't a valid Controller Action on the "hello" controller. Did you mean "update"?  │
│ Stimulus LSP (stimulus.controller.action.invalid)                                          │
├────────────────────────────────────────────────────────────────────────────────────────────┤
│  View Problem (⌥F8)   Quick-Fix... (⌘.)                                                    │
└────────────────────────────────────────────────────────────────────────────────────────────┘
                        ┌─────────────────────────────────────────────┐
                        │ Quick-Fix                                   │
                        ├─────────────────────────────────────────────┤
                        │ Replace "greet" with suggestion: "update"   │
                        └─────────────────────────────────────────────┘

-->

Executing that action would update the HTML template accordingly and resolve the diagnostic:

- <button data-controller="hello" data-action="click->hello#greet">
+ <button data-controller="hello" data-action="click->hello#update">

Resolved via #200