-
Notifications
You must be signed in to change notification settings - Fork 63
Conversation
function getESTreeType(syntaxKind) { | ||
const tsSyntaxKindName = ts.SyntaxKind[syntaxKind]; | ||
|
||
return parser.Syntax[tsSyntaxKindName] || `TS${tsSyntaxKindName}`; |
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.
this is not always a case, sometimes names do change, i don't think it's good idea..
i think its better to import types from
https://github.com/JamesHenry/typescript-estree/blob/master/src/ast-node-types.ts
"typescript-estree/dist/ast-node-types.js"
with that we don't have to convert names back and forward...
number (SyntaxKind) -> string (SyntaxKind) -> string (not always correct ts node)
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.
That is what I'm doing; parser.Syntax
is pulling from there, it just seemed right to do it through typescript-eslint-parser
as opposed to directly referencing typescript-estree
. The second case is just backup for nodes missing from the file you linked.
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.
there are also nodes not present in ts, like TSTypeParameterDeclaration
, TSTypeParameterInstantiation
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.
Oh hmm, I didn't see your edit. Let me see if that works better.
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.
also in some rare cases this using conversion ts.SyntaxKind[syntaxKind]
will return you invalid name
this enum contains also FirstAssignment
, LastAssignment
and so on, it will convert it to last key from enum with provided value
for example:
instead of TemplateTail
you will get LastTemplateToken
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.
TemplateTail
is not present in estree its called TemplateElement
:)
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.
Yup, I totally see your point. I'll put together a different approach later today.
@@ -126,7 +126,7 @@ | |||
| [`arrow-parens`] | 🌟 | [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens) | | |||
| [`arrow-return-shorthand`] | 🌟 | [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style) | | |||
| [`binary-expression-operand-order`] | 🌟 | [`yoda`](https://eslint.org/docs/rules/yoda) | | |||
| [`callable-types`] | 🛑 | N/A | | |||
| [`callable-types`] | ✅ | [`typescript/callable-types`] | |
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.
Don’t forget to add this reference to the section at the bottom of the page so the link works properly.
Co-Authored-By: uniqueiniquity <uniqueiniquity@users.noreply.github.com>
One thing I'm curious about here - how come this rule requires the parser services? |
@bradzacher you are correct, but there has to be some changes done before we can merge it :) |
extraDescription: [util.tslintRule("callable-types")], | ||
url: util.metaDocsUrl("callable-types"), | ||
}, | ||
fixable: "code", // or "code" or "whitespace" |
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.
Can you remove this comment?
fixable: "code", // or "code" or "whitespace" | |
fixable: "code", |
docs: { | ||
description: | ||
"Use function types instead of interfaces with call signatures", | ||
category: "Style", |
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.
Should this be TypeScript
instead?
extraDescription
)../utils
.Adds callable-types rule from TSLint. Depends on eslint/typescript-eslint-parser#568 for node mapping.