Closed SampsonCrowley closed 3 months ago
You don't have to use the JavaScript helpers provided for loading. You can certainly also do so by hand. But the point of a convention is to stick with one way of doing it by default, so that's what we're doing here.
https://stimulus.hotwired.dev/reference/controllers#naming-conventions
from the stimulus docs, I would think using the
eagerLoadControllersFrom
andlazyLoadControllersFrom
would allow me to decide the conventions for my js controller file namesIMO kebab case is much less surprising in the mapping from filename to controller and better matches JS conventions (don't get me wrong, ruby files should be underscored, but I like kebab for JS)
but the code for eager and lazy load:
only matches underscored names (unless you mix and match which is the worst of both worlds)
I think there should be a very small update to change
RegExp(
^${under}/._controller$)
toRegExp(
^${under}/.[_-]controller$)
and in
controllerFilename
it should also parse the import map and return the first matche.g.