stimulus-lsp icon indicating copy to clipboard operation
stimulus-lsp copied to clipboard

none of my controllers are "registered" on my Stimulus Application

Open pjmelling opened this issue 1 year ago • 3 comments

I'm getting this warning in all of my Stimulus controllers: Stimulus: The "dropdown" controller isn't registered on your Stimulus Application

This results in linting errors throughout the codebase that look like "dropdown" isn't a valid Stimulus controller. But the app works as expected; my controllers are loaded and run as expected. I whipped up a new vanilla rails app with all the defaults and the plugin doesn't complain at all. So I have to assume it's something with my codebase.

I've verified that I have the expected files in the expected locations. I have a app/javascript/application.js file, a app/javascript/controllers/index.js file, and my controllers all live in app/javascript/controllers/. The index.js file looks like this:

import { application } from "controllers/application"

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)
eagerLoadControllersFrom("component_controllers", application)

Environment Ruby: 3.4.1 Rails: 8.0.1 stimulus-rails gem: 1.3.4 Cursor Version: 0.45.15 VSCode Version: 1.96.2 Stimulus LSP plugin: 1.0.4

Where can I look next to resolve this?

Image

pjmelling avatar Feb 21 '25 20:02 pjmelling

Hey @pjmelling, thank you for the report!

Does your dropdown controller live in component_controllers/? If so, we might not respect controllers in non-default locations for importmaps. If that's the case, we might be able to fix that.

The other question is, does it work for any controller that lives in controllers/?

marcoroth avatar Mar 18 '25 16:03 marcoroth

I have a a similar issue. Controllers are in app/javascript/supporters-app/controllers

Skotar avatar Apr 17 '25 13:04 Skotar

Similar issue here, the default location controllers work for us, but the controllers we keep with our components as sidecar in app/components/**/* are not found.

ahmeij avatar Oct 01 '25 14:10 ahmeij