marcoroth/stimulus-lsp

Code Action: Register unregistered Stimulus controller

Closed this issue · 0 comments

Often times, when you create a new Stimulus controller and you are manually registering them on the Stimulus application you might forget to do so.

We can detect when a Stimulus controller exists in a file and wasn't registered on the Application. Like, if we create a controller in the file hello_controller.js and we have this in app/javascript/controllers/index.js:

import { application } from "./application"

import SomeController from "./some_controller"
application.register("some", SomeController)

We can suggest to import the hello controller too:

import { application } from "./application"

import SomeController from "./some_controller"
application.register("some", SomeController)

+ import HelloController from "./hello_controller"
+ application.register("hello", HelloController)