hegel
hegel copied to clipboard
Suggestion for easy "editor" integration, leverage eslint plugin.
I wanted to integrate my own typechecker into my text editor and did not feel like writing a vs code / vim / etc plugin.
I ended up leveraging eslint
( https://github.com/Raynos/eslint-plugin-jsig ).
As long as eslint can parse your source code by configuring it to use babel ( https://eslint.org/docs/user-guide/configuring#specifying-parser ).
Then the eslint plugin can just import the type checker CLI and run it. You may need to add a --fileName
parameter to the CLI to configure it to run on only one filename.
Here is an example eslint plugin that uses a type checker and will write text to a temporary file if eslint is running on "text" instead of a file ( https://github.com/Raynos/eslint-plugin-jsig/blob/master/type-check-rule.js#L39-L62 ).
Eslint already has a vs code plugin and a vim plugin and an X plugin ( https://eslint.org/docs/user-guide/integrations#editors ).
There's still value in a first class editor plugin, but an eslint plugin can get a lot of bang for buck for all the other editors by just running the type checker and converting the type checker errors into eslint rule errors.