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
Figure out the next step toward plugin system. #2079
Comments
On top of my head I see 2 options: 1/ expose an |
Hooks you need:
Other things you need:
At least, in my head, that's the most elegant and maybe workable solution, using the fewest hacks. |
What is a |
A symbol representing a sequence of symbols scanned from the source code, part of the formal grammar of the language. To add new parsing rules, you'd need to add rules for new productions. That would be easily pluggable. To add new linting rules, you'd add new rules for generating errors from grammar productions (or more complex analysis). I'm not sure there is a better way to make linting pluggable. For simple rules, you could even define a domain specific Language for creating the rules for generating errors. It would be a pretty substantial rewrite of the current architecture, but we've discussed it a bit |
@caitp sounds good, but how long is this going to take? A couple of things that struck me when I wrote the
|
Arguably, this is another reason to move away from the current parsing strategy ;) It's hard for people to understand, and potentially leads to code duplication.
Well sure, but ideally you shouldn't be dealing with tokens directly anyways.
I believe the handling of arrow functions has already been unified by @jugglinmike, although I didn't pay much attention to his patch, so it might not be as unified as I believe. |
What I meant is that it is not unified with the |
I understood you ;) I don't think it's necessarily worth doing that. There are two cases which can be arrow functions: |
@caitp yeah I think this is what is fundamentally wrong in a lot of places the current code, should be only in one place, because when it combine with other patterns, you have to multiply by 2 so complexity increases quickly. |
FYI, this is the raw api I've extracted for the asyncAwait code (The part exposed to the actual plugin implementation). It's crap (I have to do with the current code), but it works and passes all the tests. I am going to iterate on this and see where it goes. var pluginApi = {
addlabel: addlabel,
advance: advance,
doFunction: doFunction,
blockstmt: blockstmt,
error: error,
expression: expression,
funct: function () { return funct; },
inblock: function() { return inblock; },
isEndOfExpr: isEndOfExpr,
nobreaknonadjacent: nobreaknonadjacent,
nolinebreak: nolinebreak,
optionalidentifier: optionalidentifier,
peek : peek,
prefix: prefix,
warning: warning,
warningAt: warningAt
}; |
See the ugly (but working) #2077 PR to get an idea what is needed. @rwaldron was mentioning the need for a common design effort.
In short we need to expose a lot of internals, plugins would need to do stuff like registering prefix, statement call error/warnings, so the question is what is the best way to do that?
The text was updated successfully, but these errors were encountered: