pulsar-linter / linter-eslint-node

ESLint plugin for Atom/Pulsar Linter (v8 and above)
https://web.pulsar-edit.dev/packages/linter-eslint-node
MIT License
2 stars 0 forks source link

Investigate: Pulsar ESLint package as language client #25

Open savetheclocktower opened 3 months ago

savetheclocktower commented 3 months ago

I haven’t forgotten about this package; just haven’t had time to think about the best way to go forward. But after recent experiments with language servers/clients in other projects, I got the idea a few days ago to see whether this package could eventually graduate to a package that consumes ESLint as a language server.

Since that’s how VSCode’s ESLint support is delivered, I wondered if we could just use the server they wrote for VSCode, then write our own client by wrapping atom-languageclient. That’s how pulsar-ide-typescript-alpha was implemented and it’s been a joy to use.

Here are some notes for posterity:

Conclusion

Here’s what would have to happen if we wanted this package’s successor to be one that consumes VSCode’s ESLint language server.

In order to deliver a package that can lint on save, plus deliver suggested fixes and links to rule documentation:

In order to go further and deliver a package that can lint on every change:

What should happen instead?

Whether they realize it or not, ESLint needs to write their own language server. That’s the direction that this discussion drifted toward (though it’s 14 months old).

The pain points with ESLint are especially acute considering how easy it was to write a Pulsar package for for Biome — a project that aims to supplant both ESLint and Prettier. The Biome folks correctly surmised that they’d need to implement their own language server in order to enjoy wide editor support. And their diagnostics — like those of all other language servers I’ve used — are initiated by the server and Just Work.

ESLint, on the other hand, is a tool that originally expected to be run against one file at a time in a terminal session, but is now mainly used in interactive fashion by developers in IDEs. One theory of mine is that this “pull” style of diagnostic retrieval only exists because the client needed to work around ESLint’s limitations (whether performance or single-file awareness) by telling the server which files needed to be linted, rather than vice-versa.

Since that won’t happen, what should we do?

I think it’s still worth trying to steal borrow use (it’s MIT-licensed!) some of VSCode’s ESLint code, since they’ve got support for both kinds of config files now. There might at least be some tricks or approaches we could learn from.

scagood commented 1 month ago

I think that it probably would be worth it to add eslint as a language server, but I think it'd be better to have a language server base package, instead of a linter.


That in turn would resolve most of the issues which this entire repo tried to solve 🤔