-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC: loadable plugin [DONT MERGE] #4071
Conversation
I think this would be the right way to go. It would make it easy to find for someone looking to contribute to the plugin system. |
CodSpeed Performance ReportMerging #4071 will degrade performances by 6.58%Comparing Summary
Benchmarks breakdown
|
Awesome to see this coming together! I'm not sure I like using rewrites for the diagnostics:
I'd lean towards either:
|
@morgante Makes sense! I think I’d towards the |
Meaning yet another ~40 binaries dependency with a significant size? Or the plugin DSO is ABI independent? Guys, the former it's not sustainable. Please consider an ABI agnostic alternative with minimum overhead like wasm. |
@jerome-benoit No, we're just talking about putting the bulk of the logic for the plugin system in another crate, which biome depends on (like we already do for most major modules). I'd highly recommend reading up on the plugins RFC and related threads. They should give you all the context you need for this PR. |
I would think in the long run, and make the plugins a top level configuration. I don't see any particular reason to start from the linter. We could craft the loading of the manifest this way // biome.json
{
"plugins": ["./some-plugin"] // it could be npm package too
} Then inside the // biome.manifest
{
"version": "",
"rules": ["./path/to/rule.grit"]
}
Yes, it must be. We should use the same loading logic we use for the
Yes, it make sense. How would a user define which language a plugin is able to interact with?
I don't know much about grit, but can I user-pass a text range to the diagnostic? A text range isn't always the node that is being queried. I don't want to be a downer, however I wonder if we could be more strict about the messages of the rules. In Biome we try to enforce the three rule pillars in our rules, and I wonder if we should do the same for the rule plugins too. |
Thanks, I like the idea for plugin manifests. That’ll indeed allow us to create more comprehensive plugins down the line 👍
Maybe this should also be defined in the manifest then?
In this snippet, the first argument to
So you’re not explicitly passing ranges, but something that you can match on. But the query allows you to use as many variables as you need, so you retain the freedom to decide on which part to report the diagnostic.
If you want really wanted, we could mandate that every rule plugin defines a rewrite rule, so there is always a code action. Thankfully they’re very easy to declare with Grit, but I’m still skeptical that’s what we should do. We know there’s situations where even providing an unsafe fix can be daunting, so if we mandate it we may just risk a repeat of the situation with mandatory suppression reasons: people will fill in nonsensical workarounds and blame us for the silly restrictions. |
Real implementation is happening here: #4234 |
Summary
This PR extends the analyzer to dynamically execute a plugin that is defined in the configuration file. This PR is intentionally implemented without too much attention for detail, so that I can solicit feedback about the direction, before cleaning stuff up.
Open questions:
plugins
section to the linter configuration. This should be extended still to support plugin options, but how do we feel about this otherwise? Discussion can also go here: ☂️ Linter plugin configuration #2458biome_analyze
doesn't have to depend on Grit and OXC resolver directly.Analyzer
struct like this?This is not in the PR yet, but I would continue along this path unless someone has a better suggestion :)