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

False Positive - "bs" isn't a valid Stimulus controller. Did you mean "maps"?Stimulus LSP(stimulus.controller.invalid)

Open fig opened this issue 2 years ago • 7 comments

I'm using the Bootstrap CSS framework which uses data-bs-xxx attributes for some elements. Stimulus LSP is picking these up and reporting them as "bs" isn't a valid Stimulus controller.

image

fig avatar Nov 06 '23 08:11 fig

Thanks for reporting this one, @fig!

I'm not quite sure how and if we can solve this. But I'm wondering if we could have an option to maintain an "ignorelist" of identifiers for which Stimulus LSP shouldn't report warnings.

marcoroth avatar Nov 07 '23 06:11 marcoroth

@marcoroth , I'm afraid I don't have a clue either. :shrug: I'm not very familiar with the internals of the JavaScript LSP space. Would it be possible to scan the internals to register "foreign" JS modules (or whatever they're called). An "ignorelist" sounds like a bit of a shotgun approach, to me.

Now I'm wondering, how does Stimulus deal with naming collisions with third party libraries?

fig avatar Nov 07 '23 07:11 fig

Ah, wait! Stimulus requires a data-controller to be declared in a parent element. Maybe this is the seam we are looking for? Stimulus-LSP should check parent nodes. Maybe it already does? Mind you, if we disregard targets outwith a related controller, that kind of negates the purpose of detecting unregistered Targets? This is not shotgun surgery, It's a circular firing squad!

fig avatar Nov 07 '23 07:11 fig

Looking for the data-controller attribute would only work if the controller is within the same file.

This might be given for most cases, but there's also the use-case where you have the controller elements in different views/partials/components.

marcoroth avatar Nov 09 '23 18:11 marcoroth

Instead of a standard "ignorelist", maybe we can provide the LSP an "ignorelist" on initialization?

This has the benefit that we leave the choice of what to ignore to the client and it also sets up further customization in the future. It does require some more setup...

https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#workspace_configuration https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#workspace_didChangeConfiguration

Gert-JanPeeters avatar Nov 10 '23 11:11 Gert-JanPeeters

Did anyone work out a workaround for this? Thanks!

christopher-b avatar Mar 05 '24 19:03 christopher-b

...suffering from the same issue. I tend to use "data-bs" quite a lot and I see quite a lot of red messages. Any ideas how to make stimulus-lsp ignore it (except uninstall stimulus-lsp)? Thanks

pruzicka avatar Mar 16 '24 19:03 pruzicka

Same issue here. Any news? I think the ignorelist is the best way forward here. Any way to help?

sandrods avatar May 22 '24 20:05 sandrods

I wanted to keep the LSP config-free so you don't have to check anything into the repo. But I guess an ignorelist only really works practically when it's checked in so teammates don't have to ignore the same controller identifiers all over again.

Or maybe we can offer both, like a per project ignorelist that just lives in your editor and isn't commited to the repo and one option where we would commit a file to the repo.

And we could ask the user which strategy they want to use whenever they are ignoring a controller identifier.

marcoroth avatar May 23 '24 04:05 marcoroth

Hey @fig, @christopher-b, @pruzicka and @sandrods 👋🏼 I just published v1.0.3 which allows to configure an ignorelist for HTML attributes and Controller identifiers through quick-fix actions. Let me know how that works for you, thank you!

https://github.com/marcoroth/stimulus-lsp/releases/tag/v1.0.3

marcoroth avatar May 23 '24 11:05 marcoroth

Works like a charm. Thank you very much.

fig avatar May 23 '24 12:05 fig

Awsome, thanks for the quick feedback! 🙌🏼

marcoroth avatar May 23 '24 12:05 marcoroth

I'm getting an error "URI must contain a scheme" in nvim when trying to run the code actions:

[ERROR][2024-05-23 15:25:13] .../vim/lsp/rpc.lua:734  "rpc" "/home/cbennell/.local/share/nvim/mason/bin/stimulus-language-server" "stderr"  "/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-searver/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565
                        responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
                                               ^

ResponseError: ...bin/squashfs-root/usr/share/nvim/runtime/lua/vim/uri.lua:107: URI must contain a scheme: /home/cbennell/src/ultima7/.stimulus-lsp/config.json
    at handleResponse (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:48)
    at handleMessage (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:13)
    at processMessageQueue (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:17)
    at Immediate.<anonymous> (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:13)
    at process.processImmediate (node:internal/timers:478:21) {
  code: -32603,
  data: undefined
}

Node.js v21.7.1

[ERROR][2024-05-23 15:25:13] .../lua/vim/lsp.lua:1085 "LSP[stimulus_ls]"  "on_error"  {  code = "SERVER_REQUEST_HANDLER_ERROR",  err = "...bin/squashfs-root/usr/share/nvim/runtime/lua/vim/uri.lua:107: URI must contain a scheme: /home/cbennell/src/ultima7/.stimulus-lsp/config.json"}

Is there any other info I can provide to help debug this?

christopher-b avatar May 23 '24 19:05 christopher-b

Thanks for reporting @christopher-b, I opened #290 to address this! Going to release a patch version including that fix soon!

marcoroth avatar May 24 '24 12:05 marcoroth

@christopher-b I published v1.0.4 to address this

marcoroth avatar Jun 02 '24 15:06 marcoroth

Thanks again, @marcoroth, for releasing and allowing us all to use this awesome tool. Thank you for responding to and supporting your community. ❤️

fig avatar Jun 02 '24 21:06 fig

@christopher-b I published v1.0.4 to address this

Thank you, @marcoroth!

christopher-b avatar Jun 03 '24 14:06 christopher-b

Thank you, for reporting back so quick! 🙌🏼

marcoroth avatar Jun 03 '24 16:06 marcoroth