sublimelsp / LSP-eslint

ESLint support for Sublime LSP plugin
MIT License
34 stars 5 forks source link

Support for .jsx files? #46

Closed mstade closed 2 years ago

mstade commented 2 years ago

Hi – great work on this plugin!

Try as I might I can't seem to get this to work properly with .jsx files though, is this supported out of the box? I do see LSP-eslint mentioned in the status bar when opening a .jsx file, and if I introduce an error it updates the count so it seems it does load properly, but it doesn't show any underlines or gutter dots and auto fixing doesn't work specifically for files saved with the .jsx extension. If I rename the same file to .js it works just fine however.

I've looked through the default configuration to see if there's anything there to help, but I can't figure this out – could you point me in the right direction?

rchl commented 2 years ago

Does your project have any eslint-jsx specific configuration? You most likely need that.

If you can't figure it out then please create a small repository that reproduce your problem.

mstade commented 2 years ago

It does, in the sense that I've added the react plugin and enabled the following parser options:

"parserOptions": {
  "ecmaFeatures": {
    "jsx": true
  }
}

I've been spending the morning trying to tweak settings and things to see if it makes any difference, but it seems it doesn't. I also ran the troubleshooting command in Sublime and while it spits out a number of things I think the following was the most interesting:

Screenshot 2021-09-22 at 15 05 22

And like I mentioned before, the status in the bottom left (I've enabled warning/error numbers in the global LSP settings) do change if I introduce errors so it certainly seems that lsp-eslint is indeed active, it just doesn't display any visual indicators of errors and warnings, and it doesn't fix anything on save like it does with regular .js files.

Is there some verbose logging I can turn on somehow, that could potentially help pinpoint the issue? I've also tried disabling other plugins but it doesn't seem to have any effect. I'll see about creating a reproducible case, but I'm really shooting in the dark here.

rchl commented 2 years ago

ST4 ships with JSX syntax so I would probably suggest removing the JSX package. That would potentially also fix your issue since then the scope would be source.jsx and the eslint server would receive a proper languageId.

mstade commented 2 years ago

That did the trick – thank you so much for the assist @rchl! Believe it or not, this is one of the first things I tried, but I never restarted Sublime and so I reinstalled the package to get the syntax support back. Removing the package and restarting Sublime solved my problem, and now lsp-eslint works just as beautifully as it does with regular ol' .js files.

I'd be happy to contribute a blurb about this in the readme, if you're accepting PRs?

rchl commented 2 years ago

I've just pushed a change that should hopefully also make it work with the legacy JSX package so we don't need to add any notes then.

mstade commented 2 years ago

That's brilliant @rchl – thank you! I've just tested it and can confirm it seems to work fine with the JSX package. Thank you for your time and effort, you've been very helpful!