Cleanup {JSXOpeningElement,TSClassImplements,TSInterfaceHeritage}.typeParameters (#18028)
This commit is contained in:
1 parent
a8c033a493
commit
65d1dfb422
3 files changed
+4
-22
No files matched your search
@@ -616,18 +616,11 @@ function printJsxOpeningElement(path, options, print) {
|
||||
const { node } = path;
|
||||
|
||||
const nameHasComments =
|
||||
hasComment(node.name) ||
|
||||
hasComment(node.typeParameters) ||
|
||||
hasComment(node.typeArguments);
|
||||
hasComment(node.name) || hasComment(node.typeArguments);
|
||||
|
||||
// Don't break self-closing elements with no attributes and no comments
|
||||
if (node.selfClosing && node.attributes.length === 0 && !nameHasComments) {
|
||||
return [
|
||||
"<",
|
||||
print("name"),
|
||||
node.typeArguments ? print("typeArguments") : print("typeParameters"),
|
||||
" />",
|
||||
];
|
||||
return ["<", print("name"), print("typeArguments"), " />"];
|
||||
}
|
||||
|
||||
// don't break up opening elements with a single long text attribute
|
||||
@@ -650,7 +643,7 @@ function printJsxOpeningElement(path, options, print) {
|
||||
return group([
|
||||
"<",
|
||||
print("name"),
|
||||
node.typeArguments ? print("typeArguments") : print("typeParameters"),
|
||||
print("typeArguments"),
|
||||
" ",
|
||||
...path.map(print, "attributes"),
|
||||
node.selfClosing ? " />" : ">",
|
||||
@@ -672,7 +665,7 @@ function printJsxOpeningElement(path, options, print) {
|
||||
[
|
||||
"<",
|
||||
print("name"),
|
||||
node.typeArguments ? print("typeArguments") : print("typeParameters"),
|
||||
print("typeArguments"),
|
||||
indent(path.map(() => [attributeLine, print()], "attributes")),
|
||||
...printEndOfOpeningTag(node, options, nameHasComments),
|
||||
],
|
||||
|
||||
@@ -16,12 +16,6 @@ const additionalVisitorKeys = {
|
||||
TSJSDocNullableType: ["typeAnnotation"],
|
||||
TSJSDocNonNullableType: ["typeAnnotation"],
|
||||
|
||||
// `@typescript-eslint/typescript-estree` v6 renamed `typeParameters` to `typeArguments`
|
||||
// Remove those when babel update AST
|
||||
JSXOpeningElement: ["typeParameters"],
|
||||
TSClassImplements: ["typeParameters"],
|
||||
TSInterfaceHeritage: ["typeParameters"],
|
||||
|
||||
// Flow, missed in `flowVisitorKeys`
|
||||
NeverTypeAnnotation: [],
|
||||
SatisfiesExpression: ["expression", "typeAnnotation"],
|
||||
@@ -38,8 +32,6 @@ const excludeKeys = {
|
||||
// From `flowVisitorKeys`
|
||||
ArrowFunctionExpression: ["id"],
|
||||
FunctionExpression: ["predicate"],
|
||||
// Flow don't use it, but `typescript-eslint` v6 switched to `typeArguments`
|
||||
// JSXOpeningElement: ["typeArguments"],
|
||||
// TODO: Remove `types` when babel changes AST of `TupleTypeAnnotation`
|
||||
// Flow parser changed `.types` to `.elementTypes` https://github.com/facebook/flow/commit/5b60e6a81dc277dfab2e88fa3737a4dc9aafdcab
|
||||
// TupleTypeAnnotation: ["types"],
|
||||
|
||||
@@ -496,7 +496,6 @@ exports[`visitor keys estree 1`] = `
|
||||
"attributes",
|
||||
"name",
|
||||
"typeArguments",
|
||||
"typeParameters",
|
||||
],
|
||||
"JSXOpeningFragment": [],
|
||||
"JSXSpreadAttribute": [
|
||||
@@ -826,7 +825,6 @@ exports[`visitor keys estree 1`] = `
|
||||
"TSClassImplements": [
|
||||
"expression",
|
||||
"typeArguments",
|
||||
"typeParameters",
|
||||
],
|
||||
"TSConditionalType": [
|
||||
"checkType",
|
||||
@@ -925,7 +923,6 @@ exports[`visitor keys estree 1`] = `
|
||||
"TSInterfaceHeritage": [
|
||||
"expression",
|
||||
"typeArguments",
|
||||
"typeParameters",
|
||||
],
|
||||
"TSIntersectionType": [
|
||||
"types",
|
||||
|
||||
Reference in new issue
Block a user