-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(unstable): add lint plugin ast types #27977
Conversation
3c77a85
to
55efd5f
Compare
55efd5f
to
ff163dd
Compare
export interface YieldExpression extends AstBase { | ||
type: "YieldExpression"; | ||
delegate: boolean; | ||
argument: Expression | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems sometimes we use | undefined
and other times | null
. Should we consolidate on one or is this for a certain reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In TSEStree they use null
as an empty value for all non-type nodes and undefined
as an empty value for type nodes. It's a little weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes deviations in our AST format compared to TSEStree. They are mostly a leftover for when I first started working on it and based it off of babel instead. One of the key changes why the changeset is a bit bigger is that TSEStree uses `undefined` instead of `null` as the empty value for type nodes. This is likely influenced by `tsc` which use `undefined` everywhere. The rest of the nodes use `null` though. It's a little weird, but for now it might be better to align. (extracted from #27977)
This PR strongly types the JS plugin visitor. ```ts export default { name: "foo", rules: { bar: { create(ctx) { return { // Plain ast node visitor Identifier(node) {}, // Exit visitor "Identifier:exit"(node) {}, // Custom selectors, `node` needs to be typed manually "FunctionDeclaration > Identifier"(node: Deno.lint.Identifier) {} } } } } } ``` Follow up to #27977
- Fix deviations from TSEStreeDecided to split this PR up into two ones so that this one only has the type changes. The TSEStree fixes are here #27996