From d2923691445f35f6c1af31afcce6d884e96d5893 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 20 Apr 2022 15:08:26 -0500 Subject: [PATCH] docgen: Replace fixtures with inline parsed code. (#40428) Previously in the `docgen` package test suite we relied on developers manually creating a set of files for each test that includes a reference snippet of code, a parsed AST, and an exports listing. These files weren't linked together in any way. In this patch we're removing the manual steps and inlining the code snippets inside each test in the suite. This removes a level of manual work and indirection when maintaining the tests while leaning more on `docgen`'s `engine` component, which itself does the actual parsing. --- .../fixtures/default-class-anonymous/code.js | 4 - .../default-class-anonymous/exports.json | 70 - .../test/fixtures/default-class-named/code.js | 4 - .../fixtures/default-class-named/exports.json | 86 -- .../default-function-anonymous/code.js | 4 - .../default-function-anonymous/exports.json | 73 - .../fixtures/default-function-named/ast.json | 127 -- .../fixtures/default-function-named/code.js | 4 - .../default-function-named/exports.json | 89 -- .../fixtures/default-function-named/ir.json | 7 - .../test/fixtures/default-identifier/ast.json | 141 -- .../test/fixtures/default-identifier/code.js | 6 - .../fixtures/default-identifier/exports.json | 33 - .../fixtures/default-import-default/ast.json | 122 -- .../fixtures/default-import-default/code.js | 6 - .../default-import-default/exports.json | 33 - .../default-import-default/module-code.js | 6 - .../default-import-default/module-ir.json | 7 - .../fixtures/default-import-named/ast.json | 139 -- .../fixtures/default-import-named/code.js | 6 - .../default-import-named/exports.json | 33 - .../default-import-named/module-code.js | 6 - .../default-import-named/module-ir.json | 7 - .../fixtures/default-named-export/ast.json | 162 --- .../fixtures/default-named-export/code.js | 6 - .../default-named-export/exports.json | 126 -- .../test/fixtures/default-parse-error/code.js | 11 - .../fixtures/default-parse-error/exports.json | 234 --- .../default-undocumented-nocomments/code.js | 3 - .../exports.json | 33 - .../default-undocumented-oneliner/code.js | 2 - .../exports.json | 73 - .../test/fixtures/default-variable/code.js | 4 - .../fixtures/default-variable/exports.json | 53 - .../docgen/test/fixtures/named-class/code.js | 4 - .../test/fixtures/named-class/exports.json | 88 -- .../fixtures/named-default-exported/code.js | 1 - .../named-default-exported/exports.json | 87 -- .../named-default-exported/module-code.js | 4 - .../named-default-exported/module-ir.json | 7 - .../test/fixtures/named-default/code.js | 1 - .../test/fixtures/named-default/exports.json | 87 -- .../fixtures/named-default/module-code.js | 4 - .../fixtures/named-default/module-ir.json | 7 - .../test/fixtures/named-function/code.js | 4 - .../test/fixtures/named-function/exports.json | 91 -- .../test/fixtures/named-function/ir.json | 7 - .../named-identifier-destructuring/ast.json | 327 ----- .../named-identifier-destructuring/code.js | 6 - .../exports.json | 70 - .../test/fixtures/named-identifier/ast.json | 181 --- .../test/fixtures/named-identifier/code.js | 6 - .../fixtures/named-identifier/exports.json | 70 - .../named-identifiers-and-inline/ast.json | 480 ------ .../named-identifiers-and-inline/code.js | 16 - .../named-identifiers-and-inline/exports.json | 248 ---- .../test/fixtures/named-identifiers/ast.json | 512 ------- .../test/fixtures/named-identifiers/code.js | 16 - .../fixtures/named-identifiers/exports.json | 170 --- .../test/fixtures/named-identifiers/ir.json | 17 - .../test/fixtures/named-import-named/code.js | 5 - .../fixtures/named-import-named/exports.json | 187 --- .../fixtures/named-import-namespace/ast.json | 159 -- .../fixtures/named-import-namespace/code.js | 6 - .../named-import-namespace/exports.json | 70 - .../named-import-namespace/module-code.js | 1 - .../module-exports.json | 87 -- .../named-import-namespace/module-ir.json | 7 - .../test/fixtures/named-variable/code.js | 4 - .../test/fixtures/named-variable/exports.json | 107 -- .../test/fixtures/named-variables/code.js | 5 - .../fixtures/named-variables/exports.json | 158 -- .../test/fixtures/namespace-commented/code.js | 4 - .../fixtures/namespace-commented/exports.json | 53 - .../namespace-commented/module-ir.json | 22 - .../fixtures/namespace-commented/module.js | 19 - .../docgen/test/fixtures/namespace/code.js | 1 - .../test/fixtures/namespace/exports.json | 34 - .../test/fixtures/namespace/module-ir.json | 22 - .../docgen/test/fixtures/namespace/module.js | 19 - .../test/fixtures/tags-function/code.js | 24 - .../test/fixtures/tags-function/exports.json | 230 --- .../test/fixtures/tags-variable/code.js | 7 - .../test/fixtures/tags-variable/exports.json | 107 -- .../example.ts | 3 - .../get-node.js | 363 ----- .../array-destructuring-array-type/example.ts | 3 - .../get-node.js | 281 ---- .../array-destructuring-tuple-type/example.ts | 3 - .../get-node.js | 380 ----- .../example.ts | 4 - .../get-node.js | 98 -- .../arrow-function/example.ts | 3 - .../arrow-function/get-node.js | 407 ------ .../assignment-pattern/example.ts | 3 - .../assignment-pattern/get-node.js | 233 --- .../example.ts | 4 - .../get-node.js | 194 --- .../exported-variable-declaration/example.ts | 1 - .../exported-variable-declaration/get-node.js | 182 --- .../example.ts | 4 - .../get-node.js | 550 ------- .../literal-values/example.ts | 3 - .../literal-values/get-node.js | 162 --- .../type-annotations/missing-types/example.ts | 1 - .../missing-types/get-node.js | 104 -- .../type-annotations/named-export/example.ts | 1 - .../type-annotations/named-export/get-node.js | 148 -- .../example.ts | 3 - .../get-node.js | 315 ---- .../type-annotations/simple-types/example.ts | 1 - .../type-annotations/simple-types/get-node.js | 43 - .../type-annotations/type-literals/example.ts | 11 - .../type-literals/get-node.js | 908 ------------ packages/docgen/test/get-export-entries.js | 754 ++++++---- .../test/get-intermediate-representation.js | 1295 +++++++++-------- packages/docgen/test/get-type-annotation.js | 299 ++-- 117 files changed, 1328 insertions(+), 11005 deletions(-) delete mode 100644 packages/docgen/test/fixtures/default-class-anonymous/code.js delete mode 100644 packages/docgen/test/fixtures/default-class-anonymous/exports.json delete mode 100644 packages/docgen/test/fixtures/default-class-named/code.js delete mode 100644 packages/docgen/test/fixtures/default-class-named/exports.json delete mode 100644 packages/docgen/test/fixtures/default-function-anonymous/code.js delete mode 100644 packages/docgen/test/fixtures/default-function-anonymous/exports.json delete mode 100644 packages/docgen/test/fixtures/default-function-named/ast.json delete mode 100644 packages/docgen/test/fixtures/default-function-named/code.js delete mode 100644 packages/docgen/test/fixtures/default-function-named/exports.json delete mode 100644 packages/docgen/test/fixtures/default-function-named/ir.json delete mode 100644 packages/docgen/test/fixtures/default-identifier/ast.json delete mode 100644 packages/docgen/test/fixtures/default-identifier/code.js delete mode 100644 packages/docgen/test/fixtures/default-identifier/exports.json delete mode 100644 packages/docgen/test/fixtures/default-import-default/ast.json delete mode 100644 packages/docgen/test/fixtures/default-import-default/code.js delete mode 100644 packages/docgen/test/fixtures/default-import-default/exports.json delete mode 100644 packages/docgen/test/fixtures/default-import-default/module-code.js delete mode 100644 packages/docgen/test/fixtures/default-import-default/module-ir.json delete mode 100644 packages/docgen/test/fixtures/default-import-named/ast.json delete mode 100644 packages/docgen/test/fixtures/default-import-named/code.js delete mode 100644 packages/docgen/test/fixtures/default-import-named/exports.json delete mode 100644 packages/docgen/test/fixtures/default-import-named/module-code.js delete mode 100644 packages/docgen/test/fixtures/default-import-named/module-ir.json delete mode 100644 packages/docgen/test/fixtures/default-named-export/ast.json delete mode 100644 packages/docgen/test/fixtures/default-named-export/code.js delete mode 100644 packages/docgen/test/fixtures/default-named-export/exports.json delete mode 100644 packages/docgen/test/fixtures/default-parse-error/code.js delete mode 100644 packages/docgen/test/fixtures/default-parse-error/exports.json delete mode 100644 packages/docgen/test/fixtures/default-undocumented-nocomments/code.js delete mode 100644 packages/docgen/test/fixtures/default-undocumented-nocomments/exports.json delete mode 100644 packages/docgen/test/fixtures/default-undocumented-oneliner/code.js delete mode 100644 packages/docgen/test/fixtures/default-undocumented-oneliner/exports.json delete mode 100644 packages/docgen/test/fixtures/default-variable/code.js delete mode 100644 packages/docgen/test/fixtures/default-variable/exports.json delete mode 100644 packages/docgen/test/fixtures/named-class/code.js delete mode 100644 packages/docgen/test/fixtures/named-class/exports.json delete mode 100644 packages/docgen/test/fixtures/named-default-exported/code.js delete mode 100644 packages/docgen/test/fixtures/named-default-exported/exports.json delete mode 100644 packages/docgen/test/fixtures/named-default-exported/module-code.js delete mode 100644 packages/docgen/test/fixtures/named-default-exported/module-ir.json delete mode 100644 packages/docgen/test/fixtures/named-default/code.js delete mode 100644 packages/docgen/test/fixtures/named-default/exports.json delete mode 100644 packages/docgen/test/fixtures/named-default/module-code.js delete mode 100644 packages/docgen/test/fixtures/named-default/module-ir.json delete mode 100644 packages/docgen/test/fixtures/named-function/code.js delete mode 100644 packages/docgen/test/fixtures/named-function/exports.json delete mode 100644 packages/docgen/test/fixtures/named-function/ir.json delete mode 100644 packages/docgen/test/fixtures/named-identifier-destructuring/ast.json delete mode 100644 packages/docgen/test/fixtures/named-identifier-destructuring/code.js delete mode 100644 packages/docgen/test/fixtures/named-identifier-destructuring/exports.json delete mode 100644 packages/docgen/test/fixtures/named-identifier/ast.json delete mode 100644 packages/docgen/test/fixtures/named-identifier/code.js delete mode 100644 packages/docgen/test/fixtures/named-identifier/exports.json delete mode 100644 packages/docgen/test/fixtures/named-identifiers-and-inline/ast.json delete mode 100644 packages/docgen/test/fixtures/named-identifiers-and-inline/code.js delete mode 100644 packages/docgen/test/fixtures/named-identifiers-and-inline/exports.json delete mode 100644 packages/docgen/test/fixtures/named-identifiers/ast.json delete mode 100644 packages/docgen/test/fixtures/named-identifiers/code.js delete mode 100644 packages/docgen/test/fixtures/named-identifiers/exports.json delete mode 100644 packages/docgen/test/fixtures/named-identifiers/ir.json delete mode 100644 packages/docgen/test/fixtures/named-import-named/code.js delete mode 100644 packages/docgen/test/fixtures/named-import-named/exports.json delete mode 100644 packages/docgen/test/fixtures/named-import-namespace/ast.json delete mode 100644 packages/docgen/test/fixtures/named-import-namespace/code.js delete mode 100644 packages/docgen/test/fixtures/named-import-namespace/exports.json delete mode 100644 packages/docgen/test/fixtures/named-import-namespace/module-code.js delete mode 100644 packages/docgen/test/fixtures/named-import-namespace/module-exports.json delete mode 100644 packages/docgen/test/fixtures/named-import-namespace/module-ir.json delete mode 100644 packages/docgen/test/fixtures/named-variable/code.js delete mode 100644 packages/docgen/test/fixtures/named-variable/exports.json delete mode 100644 packages/docgen/test/fixtures/named-variables/code.js delete mode 100644 packages/docgen/test/fixtures/named-variables/exports.json delete mode 100644 packages/docgen/test/fixtures/namespace-commented/code.js delete mode 100644 packages/docgen/test/fixtures/namespace-commented/exports.json delete mode 100644 packages/docgen/test/fixtures/namespace-commented/module-ir.json delete mode 100644 packages/docgen/test/fixtures/namespace-commented/module.js delete mode 100644 packages/docgen/test/fixtures/namespace/code.js delete mode 100644 packages/docgen/test/fixtures/namespace/exports.json delete mode 100644 packages/docgen/test/fixtures/namespace/module-ir.json delete mode 100644 packages/docgen/test/fixtures/namespace/module.js delete mode 100644 packages/docgen/test/fixtures/tags-function/code.js delete mode 100644 packages/docgen/test/fixtures/tags-function/exports.json delete mode 100644 packages/docgen/test/fixtures/tags-variable/code.js delete mode 100644 packages/docgen/test/fixtures/tags-variable/exports.json delete mode 100644 packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/arrow-function/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/arrow-function/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/assignment-pattern/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/assignment-pattern/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/literal-values/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/literal-values/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/missing-types/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/missing-types/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/named-export/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/named-export/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/simple-types/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/simple-types/get-node.js delete mode 100644 packages/docgen/test/fixtures/type-annotations/type-literals/example.ts delete mode 100644 packages/docgen/test/fixtures/type-annotations/type-literals/get-node.js diff --git a/packages/docgen/test/fixtures/default-class-anonymous/code.js b/packages/docgen/test/fixtures/default-class-anonymous/code.js deleted file mode 100644 index 79ca0d6a39fcd..0000000000000 --- a/packages/docgen/test/fixtures/default-class-anonymous/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Class declaration example. - */ -export default class {} diff --git a/packages/docgen/test/fixtures/default-class-anonymous/exports.json b/packages/docgen/test/fixtures/default-class-anonymous/exports.json deleted file mode 100644 index 3c62748bde3b6..0000000000000 --- a/packages/docgen/test/fixtures/default-class-anonymous/exports.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 38, - "end": 61, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 23 - } - }, - "range": [ 38, 61 ], - "declaration": { - "type": "ClassDeclaration", - "start": 53, - "end": 61, - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 23 - } - }, - "range": [ 53, 61 ], - "id": null, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 59, - "end": 61, - "loc": { - "start": { - "line": 4, - "column": 21 - }, - "end": { - "line": 4, - "column": 23 - } - }, - "range": [ 59, 61 ], - "body": [] - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 0, - "end": 37, - "range": [ 0, 37 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-class-named/code.js b/packages/docgen/test/fixtures/default-class-named/code.js deleted file mode 100644 index 91649c8da44b5..0000000000000 --- a/packages/docgen/test/fixtures/default-class-named/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Class declaration example. - */ -export default class ClassDeclaration {} diff --git a/packages/docgen/test/fixtures/default-class-named/exports.json b/packages/docgen/test/fixtures/default-class-named/exports.json deleted file mode 100644 index 689add2e9e298..0000000000000 --- a/packages/docgen/test/fixtures/default-class-named/exports.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 38, - "end": 78, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 38, 78 ], - "declaration": { - "type": "ClassDeclaration", - "start": 53, - "end": 78, - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 53, 78 ], - "id": { - "type": "Identifier", - "start": 59, - "end": 75, - "loc": { - "start": { - "line": 4, - "column": 21 - }, - "end": { - "line": 4, - "column": 37 - } - }, - "range": [ 59, 75 ], - "name": "ClassDeclaration" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 76, - "end": 78, - "loc": { - "start": { - "line": 4, - "column": 38 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 76, 78 ], - "body": [] - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 0, - "end": 37, - "range": [ 0, 37 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-function-anonymous/code.js b/packages/docgen/test/fixtures/default-function-anonymous/code.js deleted file mode 100644 index 05cb7a6684a36..0000000000000 --- a/packages/docgen/test/fixtures/default-function-anonymous/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Function declaration example. - */ -export default function () {} diff --git a/packages/docgen/test/fixtures/default-function-anonymous/exports.json b/packages/docgen/test/fixtures/default-function-anonymous/exports.json deleted file mode 100644 index bad57bf288dc2..0000000000000 --- a/packages/docgen/test/fixtures/default-function-anonymous/exports.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 41, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 28 - } - }, - "range": [ 41, 69 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 56, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 28 - } - }, - "range": [ 56, 69 ], - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 67, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 26 - }, - "end": { - "line": 4, - "column": 28 - } - }, - "range": [ 67, 69 ], - "body": [] - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-function-named/ast.json b/packages/docgen/test/fixtures/default-function-named/ast.json deleted file mode 100644 index 4be257f6725ac..0000000000000 --- a/packages/docgen/test/fixtures/default-function-named/ast.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 84, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 41, 83 ], - "body": [ - { - "type": "ExportDefaultDeclaration", - "start": 41, - "end": 83, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 41, 83 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 56, - "end": 83, - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 56, 83 ], - "id": { - "type": "Identifier", - "start": 65, - "end": 78, - "loc": { - "start": { - "line": 4, - "column": 24 - }, - "end": { - "line": 4, - "column": 37 - } - }, - "range": [ 65, 78 ], - "name": "myDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 81, - "end": 83, - "loc": { - "start": { - "line": 4, - "column": 40 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 81, 83 ], - "body": [] - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-function-named/code.js b/packages/docgen/test/fixtures/default-function-named/code.js deleted file mode 100644 index 74318a75d6ab9..0000000000000 --- a/packages/docgen/test/fixtures/default-function-named/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Function declaration example. - */ -export default function myDeclaration() {} diff --git a/packages/docgen/test/fixtures/default-function-named/exports.json b/packages/docgen/test/fixtures/default-function-named/exports.json deleted file mode 100644 index 6e7c6427a9375..0000000000000 --- a/packages/docgen/test/fixtures/default-function-named/exports.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 41, - "end": 83, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 41, 83 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 56, - "end": 83, - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 56, 83 ], - "id": { - "type": "Identifier", - "start": 65, - "end": 78, - "loc": { - "start": { - "line": 4, - "column": 24 - }, - "end": { - "line": 4, - "column": 37 - } - }, - "range": [ 65, 78 ], - "name": "myDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 81, - "end": 83, - "loc": { - "start": { - "line": 4, - "column": 40 - }, - "end": { - "line": 4, - "column": 42 - } - }, - "range": [ 81, 83 ], - "body": [] - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-function-named/ir.json b/packages/docgen/test/fixtures/default-function-named/ir.json deleted file mode 100644 index 417dddabff40a..0000000000000 --- a/packages/docgen/test/fixtures/default-function-named/ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "default", - "description": "Function declaration example.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/default-identifier/ast.json b/packages/docgen/test/fixtures/default-identifier/ast.json deleted file mode 100644 index 5136d02bcd9a3..0000000000000 --- a/packages/docgen/test/fixtures/default-identifier/ast.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 98, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 6, - "column": 32 - } - }, - "range": [ 38, 97 ], - "body": [ - { - "type": "ClassDeclaration", - "start": 38, - "end": 63, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 25 - } - }, - "range": [ 38, 63 ], - "id": { - "type": "Identifier", - "start": 44, - "end": 60, - "loc": { - "start": { - "line": 4, - "column": 6 - }, - "end": { - "line": 4, - "column": 22 - } - }, - "range": [ 44, 60 ], - "name": "ClassDeclaration" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 61, - "end": 63, - "loc": { - "start": { - "line": 4, - "column": 23 - }, - "end": { - "line": 4, - "column": 25 - } - }, - "range": [ 61, 63 ], - "body": [] - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 0, - "end": 37, - "range": [ 0, 37 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportDefaultDeclaration", - "start": 65, - "end": 97, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 32 - } - }, - "range": [ 65, 97 ], - "declaration": { - "type": "Identifier", - "start": 80, - "end": 96, - "loc": { - "start": { - "line": 6, - "column": 15 - }, - "end": { - "line": 6, - "column": 31 - } - }, - "range": [ 80, 96 ], - "name": "ClassDeclaration" - } - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 0, - "end": 37, - "range": [ 0, 37 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-identifier/code.js b/packages/docgen/test/fixtures/default-identifier/code.js deleted file mode 100644 index 2a172ecc0578f..0000000000000 --- a/packages/docgen/test/fixtures/default-identifier/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Class declaration example. - */ -class ClassDeclaration {} - -export default ClassDeclaration; diff --git a/packages/docgen/test/fixtures/default-identifier/exports.json b/packages/docgen/test/fixtures/default-identifier/exports.json deleted file mode 100644 index c45082ff55938..0000000000000 --- a/packages/docgen/test/fixtures/default-identifier/exports.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 65, - "end": 97, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 32 - } - }, - "range": [ 65, 97 ], - "declaration": { - "type": "Identifier", - "start": 80, - "end": 96, - "loc": { - "start": { - "line": 6, - "column": 15 - }, - "end": { - "line": 6, - "column": 31 - } - }, - "range": [ 80, 96 ], - "name": "ClassDeclaration" - } -} diff --git a/packages/docgen/test/fixtures/default-import-default/ast.json b/packages/docgen/test/fixtures/default-import-default/ast.json deleted file mode 100644 index 7936a04aea1e5..0000000000000 --- a/packages/docgen/test/fixtures/default-import-default/ast.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 92, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 0, 91 ], - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 60, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 60 - } - }, - "range": [ 0, 60 ], - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "start": 7, - "end": 20, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 20 - } - }, - "range": [ 7, 20 ], - "local": { - "type": "Identifier", - "start": 7, - "end": 20, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 20 - } - }, - "range": [ 7, 20 ], - "name": "fnDeclaration" - } - } - ], - "source": { - "type": "Literal", - "start": 26, - "end": 59, - "loc": { - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 1, - "column": 59 - } - }, - "range": [ 26, 59 ], - "value": "./default-import-default-module", - "raw": "'./default-import-default-module'" - } - }, - { - "type": "ExportDefaultDeclaration", - "start": 62, - "end": 91, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 62, 91 ], - "declaration": { - "type": "Identifier", - "start": 77, - "end": 90, - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 28 - } - }, - "range": [ 77, 90 ], - "name": "fnDeclaration" - } - } - ], - "sourceType": "module", - "comments": [] -} diff --git a/packages/docgen/test/fixtures/default-import-default/code.js b/packages/docgen/test/fixtures/default-import-default/code.js deleted file mode 100644 index 70619a579c57b..0000000000000 --- a/packages/docgen/test/fixtures/default-import-default/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Internal dependencies - */ -import fnDeclaration from './module-code'; - -export default fnDeclaration; diff --git a/packages/docgen/test/fixtures/default-import-default/exports.json b/packages/docgen/test/fixtures/default-import-default/exports.json deleted file mode 100644 index 2062342d8c256..0000000000000 --- a/packages/docgen/test/fixtures/default-import-default/exports.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 62, - "end": 91, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 62, 91 ], - "declaration": { - "type": "Identifier", - "start": 77, - "end": 90, - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 28 - } - }, - "range": [ 77, 90 ], - "name": "fnDeclaration" - } -} diff --git a/packages/docgen/test/fixtures/default-import-default/module-code.js b/packages/docgen/test/fixtures/default-import-default/module-code.js deleted file mode 100644 index 4da030a5b9d0a..0000000000000 --- a/packages/docgen/test/fixtures/default-import-default/module-code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Function declaration. - */ -function functionDeclaration() {} - -export default functionDeclaration; diff --git a/packages/docgen/test/fixtures/default-import-default/module-ir.json b/packages/docgen/test/fixtures/default-import-default/module-ir.json deleted file mode 100644 index 0ab4745619d94..0000000000000 --- a/packages/docgen/test/fixtures/default-import-default/module-ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "default", - "description": "Function declaration.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/default-import-named/ast.json b/packages/docgen/test/fixtures/default-import-named/ast.json deleted file mode 100644 index c6d9e84e0bb96..0000000000000 --- a/packages/docgen/test/fixtures/default-import-named/ast.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 117, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 0, 116 ], - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 85, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 85 - } - }, - "range": [ 0, 85 ], - "specifiers": [ - { - "type": "ImportSpecifier", - "start": 9, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 45 - } - }, - "range": [ 9, 45 ], - "imported": { - "type": "Identifier", - "start": 9, - "end": 28, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 28 - } - }, - "range": [ 9, 28 ], - "name": "functionDeclaration" - }, - "local": { - "type": "Identifier", - "start": 32, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 32 - }, - "end": { - "line": 1, - "column": 45 - } - }, - "range": [ 32, 45 ], - "name": "fnDeclaration" - } - } - ], - "source": { - "type": "Literal", - "start": 53, - "end": 84, - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 84 - } - }, - "range": [ 53, 84 ], - "value": "./default-import-named-module", - "raw": "'./default-import-named-module'" - } - }, - { - "type": "ExportDefaultDeclaration", - "start": 87, - "end": 116, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 87, 116 ], - "declaration": { - "type": "Identifier", - "start": 102, - "end": 115, - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 28 - } - }, - "range": [ 102, 115 ], - "name": "fnDeclaration" - } - } - ], - "sourceType": "module", - "comments": [] -} diff --git a/packages/docgen/test/fixtures/default-import-named/code.js b/packages/docgen/test/fixtures/default-import-named/code.js deleted file mode 100644 index b8e89023444b5..0000000000000 --- a/packages/docgen/test/fixtures/default-import-named/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Internal dependencies - */ -import { functionDeclaration as fnDeclaration } from './module-code'; - -export default fnDeclaration; diff --git a/packages/docgen/test/fixtures/default-import-named/exports.json b/packages/docgen/test/fixtures/default-import-named/exports.json deleted file mode 100644 index c1a3cd0d402b8..0000000000000 --- a/packages/docgen/test/fixtures/default-import-named/exports.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 87, - "end": 116, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 87, 116 ], - "declaration": { - "type": "Identifier", - "start": 102, - "end": 115, - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 28 - } - }, - "range": [ 102, 115 ], - "name": "fnDeclaration" - } -} diff --git a/packages/docgen/test/fixtures/default-import-named/module-code.js b/packages/docgen/test/fixtures/default-import-named/module-code.js deleted file mode 100644 index 7ec5c68c3fbb3..0000000000000 --- a/packages/docgen/test/fixtures/default-import-named/module-code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Function declaration. - */ -function functionDeclaration() {} - -export { functionDeclaration }; diff --git a/packages/docgen/test/fixtures/default-import-named/module-ir.json b/packages/docgen/test/fixtures/default-import-named/module-ir.json deleted file mode 100644 index f8f7a132f2277..0000000000000 --- a/packages/docgen/test/fixtures/default-import-named/module-ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "functionDeclaration", - "description": "Function declaration.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/default-named-export/ast.json b/packages/docgen/test/fixtures/default-named-export/ast.json deleted file mode 100644 index d4b8e62b1d2ac..0000000000000 --- a/packages/docgen/test/fixtures/default-named-export/ast.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 119, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 6, - "column": 35 - } - }, - "range": [ 41, 118 ], - "body": [ - { - "type": "ExportNamedDeclaration", - "start": 41, - "end": 81, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 41, 81 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 48, - "end": 81, - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 48, 81 ], - "id": { - "type": "Identifier", - "start": 57, - "end": 76, - "loc": { - "start": { - "line": 4, - "column": 16 - }, - "end": { - "line": 4, - "column": 35 - } - }, - "range": [ 57, 76 ], - "name": "functionDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 79, - "end": 81, - "loc": { - "start": { - "line": 4, - "column": 38 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 79, 81 ], - "body": [] - } - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportDefaultDeclaration", - "start": 83, - "end": 118, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 35 - } - }, - "range": [ 83, 118 ], - "declaration": { - "type": "Identifier", - "start": 98, - "end": 117, - "loc": { - "start": { - "line": 6, - "column": 15 - }, - "end": { - "line": 6, - "column": 34 - } - }, - "range": [ 98, 117 ], - "name": "functionDeclaration" - } - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-named-export/code.js b/packages/docgen/test/fixtures/default-named-export/code.js deleted file mode 100644 index bd45a875a5eb6..0000000000000 --- a/packages/docgen/test/fixtures/default-named-export/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Function declaration example. - */ -export function functionDeclaration() {} - -export default functionDeclaration; diff --git a/packages/docgen/test/fixtures/default-named-export/exports.json b/packages/docgen/test/fixtures/default-named-export/exports.json deleted file mode 100644 index e5224ece4aafc..0000000000000 --- a/packages/docgen/test/fixtures/default-named-export/exports.json +++ /dev/null @@ -1,126 +0,0 @@ -[ - { - "type": "ExportNamedDeclaration", - "start": 41, - "end": 81, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 41, 81 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 48, - "end": 81, - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 48, 81 ], - "id": { - "type": "Identifier", - "start": 57, - "end": 76, - "loc": { - "start": { - "line": 4, - "column": 16 - }, - "end": { - "line": 4, - "column": 35 - } - }, - "range": [ 57, 76 ], - "name": "functionDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 79, - "end": 81, - "loc": { - "start": { - "line": 4, - "column": 38 - }, - "end": { - "line": 4, - "column": 40 - } - }, - "range": [ 79, 81 ], - "body": [] - } - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportDefaultDeclaration", - "start": 83, - "end": 118, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 35 - } - }, - "range": [ 83, 118 ], - "declaration": { - "type": "Identifier", - "start": 98, - "end": 117, - "loc": { - "start": { - "line": 6, - "column": 15 - }, - "end": { - "line": 6, - "column": 34 - } - }, - "range": [ 98, 117 ], - "name": "functionDeclaration" - } - } -] diff --git a/packages/docgen/test/fixtures/default-parse-error/code.js b/packages/docgen/test/fixtures/default-parse-error/code.js deleted file mode 100644 index e547f39703513..0000000000000 --- a/packages/docgen/test/fixtures/default-parse-error/code.js +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable jsdoc/valid-types */ -/** - * Function invoking callback after delay with current timestamp in milliseconds - * since epoch. - * - * @param {(timestamp:number)=>void} callback Callback function. - */ -export default function invokeCallbackAfterDelay( callback ) { - setTimeout( () => callback( Date.now() ), 1000 ); -} -/* eslint-enable jsdoc/valid-types */ diff --git a/packages/docgen/test/fixtures/default-parse-error/exports.json b/packages/docgen/test/fixtures/default-parse-error/exports.json deleted file mode 100644 index 9a5fdc107de3b..0000000000000 --- a/packages/docgen/test/fixtures/default-parse-error/exports.json +++ /dev/null @@ -1,234 +0,0 @@ -[ - { - "type": "ExportDefaultDeclaration", - "start": 173, - "end": 288, - "loc": { - "start": { "line": 7, "column": 0 }, - "end": { "line": 9, "column": 1 } - }, - "range": [ 173, 288 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 188, - "end": 288, - "loc": { - "start": { "line": 7, "column": 15 }, - "end": { "line": 9, "column": 1 } - }, - "range": [ 188, 288 ], - "id": { - "type": "Identifier", - "start": 197, - "end": 221, - "loc": { - "start": { "line": 7, "column": 24 }, - "end": { "line": 7, "column": 48 } - }, - "range": [ 197, 221 ], - "name": "invokeCallbackAfterDelay" - }, - "generator": false, - "expression": false, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 223, - "end": 231, - "loc": { - "start": { "line": 7, "column": 50 }, - "end": { "line": 7, "column": 58 } - }, - "range": [ 223, 231 ], - "name": "callback" - } - ], - "body": { - "type": "BlockStatement", - "start": 234, - "end": 288, - "loc": { - "start": { "line": 7, "column": 61 }, - "end": { "line": 9, "column": 1 } - }, - "range": [ 234, 288 ], - "body": [ - { - "type": "ExpressionStatement", - "start": 237, - "end": 286, - "loc": { - "start": { "line": 8, "column": 1 }, - "end": { "line": 8, "column": 50 } - }, - "range": [ 237, 286 ], - "expression": { - "type": "CallExpression", - "start": 237, - "end": 285, - "loc": { - "start": { "line": 8, "column": 1 }, - "end": { "line": 8, "column": 49 } - }, - "range": [ 237, 285 ], - "callee": { - "type": "Identifier", - "start": 237, - "end": 247, - "loc": { - "start": { "line": 8, "column": 1 }, - "end": { "line": 8, "column": 11 } - }, - "range": [ 237, 247 ], - "name": "setTimeout" - }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "start": 249, - "end": 277, - "loc": { - "start": { "line": 8, "column": 13 }, - "end": { "line": 8, "column": 41 } - }, - "range": [ 249, 277 ], - "id": null, - "generator": false, - "expression": true, - "async": false, - "params": [], - "body": { - "type": "CallExpression", - "start": 255, - "end": 277, - "loc": { - "start": { - "line": 8, - "column": 19 - }, - "end": { "line": 8, "column": 41 } - }, - "range": [ 255, 277 ], - "callee": { - "type": "Identifier", - "start": 255, - "end": 263, - "loc": { - "start": { - "line": 8, - "column": 19 - }, - "end": { - "line": 8, - "column": 27 - } - }, - "range": [ 255, 263 ], - "name": "callback" - }, - "arguments": [ - { - "type": "CallExpression", - "start": 265, - "end": 275, - "loc": { - "start": { - "line": 8, - "column": 29 - }, - "end": { - "line": 8, - "column": 39 - } - }, - "range": [ 265, 275 ], - "callee": { - "type": "MemberExpression", - "start": 265, - "end": 273, - "loc": { - "start": { - "line": 8, - "column": 29 - }, - "end": { - "line": 8, - "column": 37 - } - }, - "range": [ 265, 273 ], - "object": { - "type": "Identifier", - "start": 265, - "end": 269, - "loc": { - "start": { - "line": 8, - "column": 29 - }, - "end": { - "line": 8, - "column": 33 - } - }, - "range": [ 265, 269 ], - "name": "Date" - }, - "property": { - "type": "Identifier", - "start": 270, - "end": 273, - "loc": { - "start": { - "line": 8, - "column": 34 - }, - "end": { - "line": 8, - "column": 37 - } - }, - "range": [ 270, 273 ], - "name": "now" - }, - "computed": false - }, - "arguments": [] - } - ] - } - }, - { - "type": "Literal", - "start": 279, - "end": 283, - "loc": { - "start": { "line": 8, "column": 43 }, - "end": { "line": 8, "column": 47 } - }, - "range": [ 279, 283 ], - "value": 1000, - "raw": "1000" - } - ] - } - } - ] - } - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function invoking callback after delay with current timestamp in milliseconds\n * since epoch.\n *\n * @param {(timestamp:number=>void} callback Callback function.\n ", - "start": 0, - "end": 172, - "range": [ 0, 172 ], - "loc": { - "start": { "line": 1, "column": 0 }, - "end": { "line": 6, "column": 3 } - } - } - ] - } -] diff --git a/packages/docgen/test/fixtures/default-undocumented-nocomments/code.js b/packages/docgen/test/fixtures/default-undocumented-nocomments/code.js deleted file mode 100644 index 444c4c6925d6b..0000000000000 --- a/packages/docgen/test/fixtures/default-undocumented-nocomments/code.js +++ /dev/null @@ -1,3 +0,0 @@ -const myDeclaration = function () {}; - -export default myDeclaration; diff --git a/packages/docgen/test/fixtures/default-undocumented-nocomments/exports.json b/packages/docgen/test/fixtures/default-undocumented-nocomments/exports.json deleted file mode 100644 index fc17908c34bc5..0000000000000 --- a/packages/docgen/test/fixtures/default-undocumented-nocomments/exports.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 38, - "end": 67, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ 38, 67 ], - "declaration": { - "type": "Identifier", - "start": 53, - "end": 66, - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 28 - } - }, - "range": [ 53, 66 ], - "name": "myDeclaration" - } -} diff --git a/packages/docgen/test/fixtures/default-undocumented-oneliner/code.js b/packages/docgen/test/fixtures/default-undocumented-oneliner/code.js deleted file mode 100644 index a685c52c46ebe..0000000000000 --- a/packages/docgen/test/fixtures/default-undocumented-oneliner/code.js +++ /dev/null @@ -1,2 +0,0 @@ -// This comment should be ignored. -export default function () {} diff --git a/packages/docgen/test/fixtures/default-undocumented-oneliner/exports.json b/packages/docgen/test/fixtures/default-undocumented-oneliner/exports.json deleted file mode 100644 index cb4c0f1887cae..0000000000000 --- a/packages/docgen/test/fixtures/default-undocumented-oneliner/exports.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 34, - "end": 63, - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 29 - } - }, - "range": [ 34, 63 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 49, - "end": 63, - "loc": { - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 29 - } - }, - "range": [ 49, 63 ], - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 60, - "end": 63, - "loc": { - "start": { - "line": 2, - "column": 26 - }, - "end": { - "line": 2, - "column": 29 - } - }, - "range": [ 60, 63 ], - "body": [] - } - }, - "leadingComments": [ - { - "type": "Line", - "value": " This comment should be ignored", - "start": 0, - "end": 33, - "range": [ 0, 33 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 33 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/default-variable/code.js b/packages/docgen/test/fixtures/default-variable/code.js deleted file mode 100644 index 2e1a56238583f..0000000000000 --- a/packages/docgen/test/fixtures/default-variable/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Variable declaration example. - */ -export default true; diff --git a/packages/docgen/test/fixtures/default-variable/exports.json b/packages/docgen/test/fixtures/default-variable/exports.json deleted file mode 100644 index e9efa0fd53d59..0000000000000 --- a/packages/docgen/test/fixtures/default-variable/exports.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "type": "ExportDefaultDeclaration", - "start": 41, - "end": 61, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 20 - } - }, - "range": [ 41, 61 ], - "declaration": { - "type": "Literal", - "start": 56, - "end": 60, - "loc": { - "start": { - "line": 4, - "column": 15 - }, - "end": { - "line": 4, - "column": 19 - } - }, - "range": [ 56, 60 ], - "value": true, - "raw": "true" - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-class/code.js b/packages/docgen/test/fixtures/named-class/code.js deleted file mode 100644 index 8310ea0c9f7f1..0000000000000 --- a/packages/docgen/test/fixtures/named-class/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * My declaration example. - */ -export class MyDeclaration {} diff --git a/packages/docgen/test/fixtures/named-class/exports.json b/packages/docgen/test/fixtures/named-class/exports.json deleted file mode 100644 index dc7a72e429b21..0000000000000 --- a/packages/docgen/test/fixtures/named-class/exports.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 35, - "end": 64, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 29 - } - }, - "range": [ 35, 64 ], - "declaration": { - "type": "ClassDeclaration", - "start": 42, - "end": 64, - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 29 - } - }, - "range": [ 42, 64 ], - "id": { - "type": "Identifier", - "start": 48, - "end": 61, - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 26 - } - }, - "range": [ 48, 61 ], - "name": "MyDeclaration" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 62, - "end": 64, - "loc": { - "start": { - "line": 4, - "column": 27 - }, - "end": { - "line": 4, - "column": 29 - } - }, - "range": [ 62, 64 ], - "body": [] - } - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-default-exported/code.js b/packages/docgen/test/fixtures/named-default-exported/code.js deleted file mode 100644 index 7aebc3a91fa1c..0000000000000 --- a/packages/docgen/test/fixtures/named-default-exported/code.js +++ /dev/null @@ -1 +0,0 @@ -export { default as moduleName } from './named-default-module'; diff --git a/packages/docgen/test/fixtures/named-default-exported/exports.json b/packages/docgen/test/fixtures/named-default-exported/exports.json deleted file mode 100644 index 0ca0cf4c377fd..0000000000000 --- a/packages/docgen/test/fixtures/named-default-exported/exports.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 0, - "end": 63, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 63 - } - }, - "range": [ 0, 63 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 9, - "end": 30, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 30 - } - }, - "range": [ 9, 30 ], - "local": { - "type": "Identifier", - "start": 9, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "range": [ 9, 16 ], - "name": "default" - }, - "exported": { - "type": "Identifier", - "start": 20, - "end": 30, - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 30 - } - }, - "range": [ 20, 30 ], - "name": "moduleName" - } - } - ], - "source": { - "type": "Literal", - "start": 38, - "end": 62, - "loc": { - "start": { - "line": 1, - "column": 38 - }, - "end": { - "line": 1, - "column": 62 - } - }, - "range": [ 38, 62 ], - "value": "./named-default-module", - "raw": "'./named-default-module'" - } -} diff --git a/packages/docgen/test/fixtures/named-default-exported/module-code.js b/packages/docgen/test/fixtures/named-default-exported/module-code.js deleted file mode 100644 index 63e7404ae54c6..0000000000000 --- a/packages/docgen/test/fixtures/named-default-exported/module-code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Module declaration. - */ -export default function () {} diff --git a/packages/docgen/test/fixtures/named-default-exported/module-ir.json b/packages/docgen/test/fixtures/named-default-exported/module-ir.json deleted file mode 100644 index 87ea21bb0aa0e..0000000000000 --- a/packages/docgen/test/fixtures/named-default-exported/module-ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "default", - "description": "Module declaration.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/named-default/code.js b/packages/docgen/test/fixtures/named-default/code.js deleted file mode 100644 index 441f6e366117f..0000000000000 --- a/packages/docgen/test/fixtures/named-default/code.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './module-code'; diff --git a/packages/docgen/test/fixtures/named-default/exports.json b/packages/docgen/test/fixtures/named-default/exports.json deleted file mode 100644 index a10a679fa39a5..0000000000000 --- a/packages/docgen/test/fixtures/named-default/exports.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 0, - "end": 49, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 49 - } - }, - "range": [ 0, 49 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 9, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "range": [ 9, 16 ], - "local": { - "type": "Identifier", - "start": 9, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "range": [ 9, 16 ], - "name": "default" - }, - "exported": { - "type": "Identifier", - "start": 9, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "range": [ 9, 16 ], - "name": "default" - } - } - ], - "source": { - "type": "Literal", - "start": 24, - "end": 48, - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 48 - } - }, - "range": [ 24, 48 ], - "value": "./named-default-module", - "raw": "'./named-default-module'" - } -} diff --git a/packages/docgen/test/fixtures/named-default/module-code.js b/packages/docgen/test/fixtures/named-default/module-code.js deleted file mode 100644 index 63e7404ae54c6..0000000000000 --- a/packages/docgen/test/fixtures/named-default/module-code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Module declaration. - */ -export default function () {} diff --git a/packages/docgen/test/fixtures/named-default/module-ir.json b/packages/docgen/test/fixtures/named-default/module-ir.json deleted file mode 100644 index 87ea21bb0aa0e..0000000000000 --- a/packages/docgen/test/fixtures/named-default/module-ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "default", - "description": "Module declaration.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/named-function/code.js b/packages/docgen/test/fixtures/named-function/code.js deleted file mode 100644 index eadb279918d04..0000000000000 --- a/packages/docgen/test/fixtures/named-function/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * My declaration example. - */ -export function myDeclaration() {} diff --git a/packages/docgen/test/fixtures/named-function/exports.json b/packages/docgen/test/fixtures/named-function/exports.json deleted file mode 100644 index d9e841dfa2177..0000000000000 --- a/packages/docgen/test/fixtures/named-function/exports.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 35, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 34 - } - }, - "range": [ 35, 69 ], - "declaration": { - "type": "FunctionDeclaration", - "start": 42, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 34 - } - }, - "range": [ 42, 69 ], - "id": { - "type": "Identifier", - "start": 51, - "end": 64, - "loc": { - "start": { - "line": 4, - "column": 16 - }, - "end": { - "line": 4, - "column": 29 - } - }, - "range": [ 51, 64 ], - "name": "myDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 67, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 32 - }, - "end": { - "line": 4, - "column": 34 - } - }, - "range": [ 67, 69 ], - "body": [] - } - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-function/ir.json b/packages/docgen/test/fixtures/named-function/ir.json deleted file mode 100644 index aa8fc8f89a456..0000000000000 --- a/packages/docgen/test/fixtures/named-function/ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "myDeclaration", - "description": "My declaration example.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/named-identifier-destructuring/ast.json b/packages/docgen/test/fixtures/named-identifier-destructuring/ast.json deleted file mode 100644 index 4db7e7ec0e889..0000000000000 --- a/packages/docgen/test/fixtures/named-identifier-destructuring/ast.json +++ /dev/null @@ -1,327 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 141, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 6, - "column": 44 - } - }, - "range": [ 35, 140 ], - "body": [ - { - "type": "VariableDeclaration", - "start": 35, - "end": 94, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 59 - } - }, - "range": [ 35, 94 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 41, - "end": 93, - "loc": { - "start": { - "line": 4, - "column": 6 - }, - "end": { - "line": 4, - "column": 58 - } - }, - "range": [ 41, 93 ], - "id": { - "type": "ObjectPattern", - "start": 41, - "end": 60, - "loc": { - "start": { - "line": 4, - "column": 6 - }, - "end": { - "line": 4, - "column": 25 - } - }, - "range": [ 41, 60 ], - "properties": [ - { - "type": "Property", - "start": 43, - "end": 58, - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 23 - } - }, - "range": [ 43, 58 ], - "method": false, - "shorthand": true, - "computed": false, - "key": { - "type": "Identifier", - "start": 43, - "end": 58, - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 23 - } - }, - "range": [ 43, 58 ], - "name": "someDeclaration" - }, - "kind": "init", - "value": { - "type": "Identifier", - "start": 43, - "end": 58, - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 23 - } - }, - "range": [ 43, 58 ], - "name": "someDeclaration" - } - } - ] - }, - "init": { - "type": "ObjectExpression", - "start": 63, - "end": 93, - "loc": { - "start": { - "line": 4, - "column": 28 - }, - "end": { - "line": 4, - "column": 58 - } - }, - "range": [ 63, 93 ], - "properties": [ - { - "type": "Property", - "start": 65, - "end": 91, - "loc": { - "start": { - "line": 4, - "column": 30 - }, - "end": { - "line": 4, - "column": 56 - } - }, - "range": [ 65, 91 ], - "method": false, - "shorthand": false, - "computed": false, - "key": { - "type": "Identifier", - "start": 65, - "end": 80, - "loc": { - "start": { - "line": 4, - "column": 30 - }, - "end": { - "line": 4, - "column": 45 - } - }, - "range": [ 65, 80 ], - "name": "someDeclaration" - }, - "value": { - "type": "ArrowFunctionExpression", - "start": 82, - "end": 91, - "loc": { - "start": { - "line": 4, - "column": 47 - }, - "end": { - "line": 4, - "column": 56 - } - }, - "range": [ 82, 91 ], - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 88, - "end": 91, - "loc": { - "start": { - "line": 4, - "column": 53 - }, - "end": { - "line": 4, - "column": 56 - } - }, - "range": [ 88, 91 ], - "body": [] - } - }, - "kind": "init" - } - ] - } - } - ], - "kind": "const", - "leadingComments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportNamedDeclaration", - "start": 96, - "end": 140, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 44 - } - }, - "range": [ 96, 140 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 105, - "end": 137, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 41 - } - }, - "range": [ 105, 137 ], - "local": { - "type": "Identifier", - "start": 105, - "end": 120, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 24 - } - }, - "range": [ 105, 120 ], - "name": "someDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 124, - "end": 137, - "loc": { - "start": { - "line": 6, - "column": 28 - }, - "end": { - "line": 6, - "column": 41 - } - }, - "range": [ 124, 137 ], - "name": "myDeclaration" - } - } - ], - "source": null - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-identifier-destructuring/code.js b/packages/docgen/test/fixtures/named-identifier-destructuring/code.js deleted file mode 100644 index 5dcad05eb2e4e..0000000000000 --- a/packages/docgen/test/fixtures/named-identifier-destructuring/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * My declaration example. - */ -const { someDeclaration } = { someDeclaration: () => {} }; - -export { someDeclaration as myDeclaration }; diff --git a/packages/docgen/test/fixtures/named-identifier-destructuring/exports.json b/packages/docgen/test/fixtures/named-identifier-destructuring/exports.json deleted file mode 100644 index ff291935c610e..0000000000000 --- a/packages/docgen/test/fixtures/named-identifier-destructuring/exports.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 96, - "end": 140, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 44 - } - }, - "range": [ 96, 140 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 105, - "end": 137, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 41 - } - }, - "range": [ 105, 137 ], - "local": { - "type": "Identifier", - "start": 105, - "end": 120, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 24 - } - }, - "range": [ 105, 120 ], - "name": "someDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 124, - "end": 137, - "loc": { - "start": { - "line": 6, - "column": 28 - }, - "end": { - "line": 6, - "column": 41 - } - }, - "range": [ 124, 137 ], - "name": "myDeclaration" - } - } - ], - "source": null -} diff --git a/packages/docgen/test/fixtures/named-identifier/ast.json b/packages/docgen/test/fixtures/named-identifier/ast.json deleted file mode 100644 index 991bc1168949f..0000000000000 --- a/packages/docgen/test/fixtures/named-identifier/ast.json +++ /dev/null @@ -1,181 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 90, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 6, - "column": 25 - } - }, - "range": [ 35, 89 ], - "body": [ - { - "type": "FunctionDeclaration", - "start": 35, - "end": 62, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 27 - } - }, - "range": [ 35, 62 ], - "id": { - "type": "Identifier", - "start": 44, - "end": 57, - "loc": { - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 22 - } - }, - "range": [ 44, 57 ], - "name": "myDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 60, - "end": 62, - "loc": { - "start": { - "line": 4, - "column": 25 - }, - "end": { - "line": 4, - "column": 27 - } - }, - "range": [ 60, 62 ], - "body": [] - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportNamedDeclaration", - "start": 64, - "end": 89, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 25 - } - }, - "range": [ 64, 89 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 73, - "end": 86, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 22 - } - }, - "range": [ 73, 86 ], - "local": { - "type": "Identifier", - "start": 73, - "end": 86, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 22 - } - }, - "range": [ 73, 86 ], - "name": "myDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 73, - "end": 86, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 22 - } - }, - "range": [ 73, 86 ], - "name": "myDeclaration" - } - } - ], - "source": null - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-identifier/code.js b/packages/docgen/test/fixtures/named-identifier/code.js deleted file mode 100644 index 8fbd063086c19..0000000000000 --- a/packages/docgen/test/fixtures/named-identifier/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * My declaration example. - */ -function myDeclaration() {} - -export { myDeclaration }; diff --git a/packages/docgen/test/fixtures/named-identifier/exports.json b/packages/docgen/test/fixtures/named-identifier/exports.json deleted file mode 100644 index 9b6f1a7896e72..0000000000000 --- a/packages/docgen/test/fixtures/named-identifier/exports.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 64, - "end": 89, - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 6, - "column": 25 - } - }, - "range": [ 64, 89 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 73, - "end": 86, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 22 - } - }, - "range": [ 73, 86 ], - "local": { - "type": "Identifier", - "start": 73, - "end": 86, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 22 - } - }, - "range": [ 73, 86 ], - "name": "myDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 73, - "end": 86, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 22 - } - }, - "range": [ 73, 86 ], - "name": "myDeclaration" - } - } - ], - "source": null -} diff --git a/packages/docgen/test/fixtures/named-identifiers-and-inline/ast.json b/packages/docgen/test/fixtures/named-identifiers-and-inline/ast.json deleted file mode 100644 index 5b684b19b3950..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers-and-inline/ast.json +++ /dev/null @@ -1,480 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 275, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 16, - "column": 40 - } - }, - "range": [ 41, 273 ], - "body": [ - { - "type": "FunctionDeclaration", - "start": 41, - "end": 74, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 33 - } - }, - "range": [ 41, 74 ], - "id": { - "type": "Identifier", - "start": 50, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 28 - } - }, - "range": [ 50, 69 ], - "name": "functionDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 72, - "end": 74, - "loc": { - "start": { - "line": 4, - "column": 31 - }, - "end": { - "line": 4, - "column": 33 - } - }, - "range": [ 72, 74 ], - "body": [] - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ], - "trailingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 76, - "end": 113, - "range": [ 76, 113 ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - } - } - ] - }, - { - "type": "ClassDeclaration", - "start": 114, - "end": 139, - "loc": { - "start": { - "line": 9, - "column": 0 - }, - "end": { - "line": 9, - "column": 25 - } - }, - "range": [ 114, 139 ], - "id": { - "type": "Identifier", - "start": 120, - "end": 136, - "loc": { - "start": { - "line": 9, - "column": 6 - }, - "end": { - "line": 9, - "column": 22 - } - }, - "range": [ 120, 136 ], - "name": "ClassDeclaration" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 137, - "end": 139, - "loc": { - "start": { - "line": 9, - "column": 23 - }, - "end": { - "line": 9, - "column": 25 - } - }, - "range": [ 137, 139 ], - "body": [] - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 76, - "end": 113, - "range": [ 76, 113 ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportNamedDeclaration", - "start": 141, - "end": 190, - "loc": { - "start": { - "line": 11, - "column": 0 - }, - "end": { - "line": 11, - "column": 49 - } - }, - "range": [ 141, 190 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 150, - "end": 169, - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 28 - } - }, - "range": [ 150, 169 ], - "local": { - "type": "Identifier", - "start": 150, - "end": 169, - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 28 - } - }, - "range": [ 150, 169 ], - "name": "functionDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 150, - "end": 169, - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 28 - } - }, - "range": [ 150, 169 ], - "name": "functionDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 171, - "end": 187, - "loc": { - "start": { - "line": 11, - "column": 30 - }, - "end": { - "line": 11, - "column": 46 - } - }, - "range": [ 171, 187 ], - "local": { - "type": "Identifier", - "start": 171, - "end": 187, - "loc": { - "start": { - "line": 11, - "column": 30 - }, - "end": { - "line": 11, - "column": 46 - } - }, - "range": [ 171, 187 ], - "name": "ClassDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 171, - "end": 187, - "loc": { - "start": { - "line": 11, - "column": 30 - }, - "end": { - "line": 11, - "column": 46 - } - }, - "range": [ 171, 187 ], - "name": "ClassDeclaration" - } - } - ], - "source": null, - "trailingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 192, - "end": 232, - "range": [ 192, 232 ], - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 15, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportNamedDeclaration", - "start": 233, - "end": 273, - "loc": { - "start": { - "line": 16, - "column": 0 - }, - "end": { - "line": 16, - "column": 40 - } - }, - "range": [ 233, 273 ], - "declaration": { - "type": "VariableDeclaration", - "start": 240, - "end": 273, - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 40 - } - }, - "range": [ 240, 273 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 246, - "end": 272, - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 16, - "column": 39 - } - }, - "range": [ 246, 272 ], - "id": { - "type": "Identifier", - "start": 246, - "end": 265, - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 16, - "column": 32 - } - }, - "range": [ 246, 265 ], - "name": "variableDeclaration" - }, - "init": { - "type": "Literal", - "start": 268, - "end": 272, - "loc": { - "start": { - "line": 16, - "column": 35 - }, - "end": { - "line": 16, - "column": 39 - } - }, - "range": [ 268, 272 ], - "value": true, - "raw": "true" - } - } - ], - "kind": "const" - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 192, - "end": 232, - "range": [ 192, 232 ], - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 15, - "column": 3 - } - } - } - ] - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - }, - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 76, - "end": 113, - "range": [ 76, 113 ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - } - }, - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 192, - "end": 232, - "range": [ 192, 232 ], - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 15, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-identifiers-and-inline/code.js b/packages/docgen/test/fixtures/named-identifiers-and-inline/code.js deleted file mode 100644 index f22043cac6503..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers-and-inline/code.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Function declaration example. - */ -function functionDeclaration() {} - -/** - * Class declaration example. - */ -class ClassDeclaration {} - -export { functionDeclaration, ClassDeclaration }; - -/** - * Variable declaration example. - */ -export const variableDeclaration = true; diff --git a/packages/docgen/test/fixtures/named-identifiers-and-inline/exports.json b/packages/docgen/test/fixtures/named-identifiers-and-inline/exports.json deleted file mode 100644 index 1d6bf92d441c9..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers-and-inline/exports.json +++ /dev/null @@ -1,248 +0,0 @@ -[ - { - "type": "ExportNamedDeclaration", - "start": 141, - "end": 190, - "loc": { - "start": { - "line": 11, - "column": 0 - }, - "end": { - "line": 11, - "column": 49 - } - }, - "range": [ 141, 190 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 150, - "end": 169, - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 28 - } - }, - "range": [ 150, 169 ], - "local": { - "type": "Identifier", - "start": 150, - "end": 169, - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 28 - } - }, - "range": [ 150, 169 ], - "name": "functionDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 150, - "end": 169, - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 28 - } - }, - "range": [ 150, 169 ], - "name": "functionDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 171, - "end": 187, - "loc": { - "start": { - "line": 11, - "column": 30 - }, - "end": { - "line": 11, - "column": 46 - } - }, - "range": [ 171, 187 ], - "local": { - "type": "Identifier", - "start": 171, - "end": 187, - "loc": { - "start": { - "line": 11, - "column": 30 - }, - "end": { - "line": 11, - "column": 46 - } - }, - "range": [ 171, 187 ], - "name": "ClassDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 171, - "end": 187, - "loc": { - "start": { - "line": 11, - "column": 30 - }, - "end": { - "line": 11, - "column": 46 - } - }, - "range": [ 171, 187 ], - "name": "ClassDeclaration" - } - } - ], - "source": null, - "trailingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 192, - "end": 232, - "range": [ 192, 232 ], - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 15, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportNamedDeclaration", - "start": 233, - "end": 273, - "loc": { - "start": { - "line": 16, - "column": 0 - }, - "end": { - "line": 16, - "column": 40 - } - }, - "range": [ 233, 273 ], - "declaration": { - "type": "VariableDeclaration", - "start": 240, - "end": 273, - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 40 - } - }, - "range": [ 240, 273 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 246, - "end": 272, - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 16, - "column": 39 - } - }, - "range": [ 246, 272 ], - "id": { - "type": "Identifier", - "start": 246, - "end": 265, - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 16, - "column": 32 - } - }, - "range": [ 246, 265 ], - "name": "variableDeclaration" - }, - "init": { - "type": "Literal", - "start": 268, - "end": 272, - "loc": { - "start": { - "line": 16, - "column": 35 - }, - "end": { - "line": 16, - "column": 39 - } - }, - "range": [ 268, 272 ], - "value": true, - "raw": "true" - } - } - ], - "kind": "const" - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 192, - "end": 232, - "range": [ 192, 232 ], - "loc": { - "start": { - "line": 13, - "column": 0 - }, - "end": { - "line": 15, - "column": 3 - } - } - } - ] - } -] diff --git a/packages/docgen/test/fixtures/named-identifiers/ast.json b/packages/docgen/test/fixtures/named-identifiers/ast.json deleted file mode 100644 index a5dc9a315ca74..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers/ast.json +++ /dev/null @@ -1,512 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 288, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 16, - "column": 70 - } - }, - "range": [ 41, 287 ], - "body": [ - { - "type": "FunctionDeclaration", - "start": 41, - "end": 74, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 33 - } - }, - "range": [ 41, 74 ], - "id": { - "type": "Identifier", - "start": 50, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 28 - } - }, - "range": [ 50, 69 ], - "name": "functionDeclaration" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 72, - "end": 74, - "loc": { - "start": { - "line": 4, - "column": 31 - }, - "end": { - "line": 4, - "column": 33 - } - }, - "range": [ 72, 74 ], - "body": [] - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ], - "trailingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 76, - "end": 113, - "range": [ 76, 113 ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - } - } - ] - }, - { - "type": "ClassDeclaration", - "start": 114, - "end": 139, - "loc": { - "start": { - "line": 9, - "column": 0 - }, - "end": { - "line": 9, - "column": 25 - } - }, - "range": [ 114, 139 ], - "id": { - "type": "Identifier", - "start": 120, - "end": 136, - "loc": { - "start": { - "line": 9, - "column": 6 - }, - "end": { - "line": 9, - "column": 22 - } - }, - "range": [ 120, 136 ], - "name": "ClassDeclaration" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 137, - "end": 139, - "loc": { - "start": { - "line": 9, - "column": 23 - }, - "end": { - "line": 9, - "column": 25 - } - }, - "range": [ 137, 139 ], - "body": [] - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 76, - "end": 113, - "range": [ 76, 113 ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - } - } - ], - "trailingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 141, - "end": 181, - "range": [ 141, 181 ], - "loc": { - "start": { - "line": 11, - "column": 0 - }, - "end": { - "line": 13, - "column": 3 - } - } - } - ] - }, - { - "type": "VariableDeclaration", - "start": 182, - "end": 215, - "loc": { - "start": { - "line": 14, - "column": 0 - }, - "end": { - "line": 14, - "column": 33 - } - }, - "range": [ 182, 215 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 188, - "end": 214, - "loc": { - "start": { - "line": 14, - "column": 6 - }, - "end": { - "line": 14, - "column": 32 - } - }, - "range": [ 188, 214 ], - "id": { - "type": "Identifier", - "start": 188, - "end": 207, - "loc": { - "start": { - "line": 14, - "column": 6 - }, - "end": { - "line": 14, - "column": 25 - } - }, - "range": [ 188, 207 ], - "name": "variableDeclaration" - }, - "init": { - "type": "Literal", - "start": 210, - "end": 214, - "loc": { - "start": { - "line": 14, - "column": 28 - }, - "end": { - "line": 14, - "column": 32 - } - }, - "range": [ 210, 214 ], - "value": true, - "raw": "true" - } - } - ], - "kind": "const", - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 141, - "end": 181, - "range": [ 141, 181 ], - "loc": { - "start": { - "line": 11, - "column": 0 - }, - "end": { - "line": 13, - "column": 3 - } - } - } - ] - }, - { - "type": "ExportNamedDeclaration", - "start": 217, - "end": 287, - "loc": { - "start": { - "line": 16, - "column": 0 - }, - "end": { - "line": 16, - "column": 70 - } - }, - "range": [ 217, 287 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 226, - "end": 245, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 28 - } - }, - "range": [ 226, 245 ], - "local": { - "type": "Identifier", - "start": 226, - "end": 245, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 28 - } - }, - "range": [ 226, 245 ], - "name": "functionDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 226, - "end": 245, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 28 - } - }, - "range": [ 226, 245 ], - "name": "functionDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 247, - "end": 266, - "loc": { - "start": { - "line": 16, - "column": 30 - }, - "end": { - "line": 16, - "column": 49 - } - }, - "range": [ 247, 266 ], - "local": { - "type": "Identifier", - "start": 247, - "end": 266, - "loc": { - "start": { - "line": 16, - "column": 30 - }, - "end": { - "line": 16, - "column": 49 - } - }, - "range": [ 247, 266 ], - "name": "variableDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 247, - "end": 266, - "loc": { - "start": { - "line": 16, - "column": 30 - }, - "end": { - "line": 16, - "column": 49 - } - }, - "range": [ 247, 266 ], - "name": "variableDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 268, - "end": 284, - "loc": { - "start": { - "line": 16, - "column": 51 - }, - "end": { - "line": 16, - "column": 67 - } - }, - "range": [ 268, 284 ], - "local": { - "type": "Identifier", - "start": 268, - "end": 284, - "loc": { - "start": { - "line": 16, - "column": 51 - }, - "end": { - "line": 16, - "column": 67 - } - }, - "range": [ 268, 284 ], - "name": "ClassDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 268, - "end": 284, - "loc": { - "start": { - "line": 16, - "column": 51 - }, - "end": { - "line": 16, - "column": 67 - } - }, - "range": [ 268, 284 ], - "name": "ClassDeclaration" - } - } - ], - "source": null - } - ], - "sourceType": "module", - "comments": [ - { - "type": "Block", - "value": "*\n * Function declaration example.\n ", - "start": 0, - "end": 40, - "range": [ 0, 40 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - }, - { - "type": "Block", - "value": "*\n * Class declaration example.\n ", - "start": 76, - "end": 113, - "range": [ 76, 113 ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 8, - "column": 3 - } - } - }, - { - "type": "Block", - "value": "*\n * Variable declaration example.\n ", - "start": 141, - "end": 181, - "range": [ 141, 181 ], - "loc": { - "start": { - "line": 11, - "column": 0 - }, - "end": { - "line": 13, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-identifiers/code.js b/packages/docgen/test/fixtures/named-identifiers/code.js deleted file mode 100644 index 6c608a4eea4e7..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers/code.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Function declaration example. - */ -function functionDeclaration() {} - -/** - * Class declaration example. - */ -class ClassDeclaration {} - -/** - * Variable declaration example. - */ -const variableDeclaration = true; - -export { functionDeclaration, variableDeclaration, ClassDeclaration }; diff --git a/packages/docgen/test/fixtures/named-identifiers/exports.json b/packages/docgen/test/fixtures/named-identifiers/exports.json deleted file mode 100644 index 76c74a87e08c3..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers/exports.json +++ /dev/null @@ -1,170 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 217, - "end": 287, - "loc": { - "start": { - "line": 16, - "column": 0 - }, - "end": { - "line": 16, - "column": 70 - } - }, - "range": [ 217, 287 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 226, - "end": 245, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 28 - } - }, - "range": [ 226, 245 ], - "local": { - "type": "Identifier", - "start": 226, - "end": 245, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 28 - } - }, - "range": [ 226, 245 ], - "name": "functionDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 226, - "end": 245, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 28 - } - }, - "range": [ 226, 245 ], - "name": "functionDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 247, - "end": 266, - "loc": { - "start": { - "line": 16, - "column": 30 - }, - "end": { - "line": 16, - "column": 49 - } - }, - "range": [ 247, 266 ], - "local": { - "type": "Identifier", - "start": 247, - "end": 266, - "loc": { - "start": { - "line": 16, - "column": 30 - }, - "end": { - "line": 16, - "column": 49 - } - }, - "range": [ 247, 266 ], - "name": "variableDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 247, - "end": 266, - "loc": { - "start": { - "line": 16, - "column": 30 - }, - "end": { - "line": 16, - "column": 49 - } - }, - "range": [ 247, 266 ], - "name": "variableDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 268, - "end": 284, - "loc": { - "start": { - "line": 16, - "column": 51 - }, - "end": { - "line": 16, - "column": 67 - } - }, - "range": [ 268, 284 ], - "local": { - "type": "Identifier", - "start": 268, - "end": 284, - "loc": { - "start": { - "line": 16, - "column": 51 - }, - "end": { - "line": 16, - "column": 67 - } - }, - "range": [ 268, 284 ], - "name": "ClassDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 268, - "end": 284, - "loc": { - "start": { - "line": 16, - "column": 51 - }, - "end": { - "line": 16, - "column": 67 - } - }, - "range": [ 268, 284 ], - "name": "ClassDeclaration" - } - } - ], - "source": null -} diff --git a/packages/docgen/test/fixtures/named-identifiers/ir.json b/packages/docgen/test/fixtures/named-identifiers/ir.json deleted file mode 100644 index d4483dfd59fa7..0000000000000 --- a/packages/docgen/test/fixtures/named-identifiers/ir.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "name": "ClassDeclaration", - "description": "Class declaration example.", - "tags": [] - }, - { - "name": "functionDeclaration", - "description": "Function declaration example.", - "tags": [] - }, - { - "name": "variableDeclaration", - "description": "Variable declaration example.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/named-import-named/code.js b/packages/docgen/test/fixtures/named-import-named/code.js deleted file mode 100644 index 68e9b4499792c..0000000000000 --- a/packages/docgen/test/fixtures/named-import-named/code.js +++ /dev/null @@ -1,5 +0,0 @@ -export { - functionDeclaration, - variableDeclaration, - ClassDeclaration, -} from './named-identifiers'; diff --git a/packages/docgen/test/fixtures/named-import-named/exports.json b/packages/docgen/test/fixtures/named-import-named/exports.json deleted file mode 100644 index 4b9b6a017c5c8..0000000000000 --- a/packages/docgen/test/fixtures/named-import-named/exports.json +++ /dev/null @@ -1,187 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 0, - "end": 101, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 5, - "column": 29 - } - }, - "range": [ 0, 101 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 10, - "end": 29, - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ 10, 29 ], - "local": { - "type": "Identifier", - "start": 10, - "end": 29, - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ 10, 29 ], - "name": "functionDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 10, - "end": 29, - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ 10, 29 ], - "name": "functionDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 32, - "end": 51, - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 20 - } - }, - "range": [ 32, 51 ], - "local": { - "type": "Identifier", - "start": 32, - "end": 51, - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 20 - } - }, - "range": [ 32, 51 ], - "name": "variableDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 32, - "end": 51, - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 20 - } - }, - "range": [ 32, 51 ], - "name": "variableDeclaration" - } - }, - { - "type": "ExportSpecifier", - "start": 54, - "end": 70, - "loc": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 4, - "column": 17 - } - }, - "range": [ 54, 70 ], - "local": { - "type": "Identifier", - "start": 54, - "end": 70, - "loc": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 4, - "column": 17 - } - }, - "range": [ 54, 70 ], - "name": "ClassDeclaration" - }, - "exported": { - "type": "Identifier", - "start": 54, - "end": 70, - "loc": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 4, - "column": 17 - } - }, - "range": [ 54, 70 ], - "name": "ClassDeclaration" - } - } - ], - "source": { - "type": "Literal", - "start": 79, - "end": 100, - "loc": { - "start": { - "line": 5, - "column": 7 - }, - "end": { - "line": 5, - "column": 28 - } - }, - "range": [ 79, 100 ], - "value": "./named-identifiers", - "raw": "'./named-identifiers'" - } -} diff --git a/packages/docgen/test/fixtures/named-import-namespace/ast.json b/packages/docgen/test/fixtures/named-import-namespace/ast.json deleted file mode 100644 index 19379c429c143..0000000000000 --- a/packages/docgen/test/fixtures/named-import-namespace/ast.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "type": "Program", - "start": 0, - "end": 85, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 21 - } - }, - "range": [ 0, 84 ], - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 61, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 61 - } - }, - "range": [ 0, 61 ], - "specifiers": [ - { - "type": "ImportNamespaceSpecifier", - "start": 7, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "range": [ 7, 21 ], - "local": { - "type": "Identifier", - "start": 12, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "range": [ 12, 21 ], - "name": "variables" - } - } - ], - "source": { - "type": "Literal", - "start": 27, - "end": 60, - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 60 - } - }, - "range": [ 27, 60 ], - "value": "./named-import-namespace-module", - "raw": "'./named-import-namespace-module'" - } - }, - { - "type": "ExportNamedDeclaration", - "start": 63, - "end": 84, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 21 - } - }, - "range": [ 63, 84 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 72, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 18 - } - }, - "range": [ 72, 81 ], - "local": { - "type": "Identifier", - "start": 72, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 18 - } - }, - "range": [ 72, 81 ], - "name": "variables" - }, - "exported": { - "type": "Identifier", - "start": 72, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 18 - } - }, - "range": [ 72, 81 ], - "name": "variables" - } - } - ], - "source": null - } - ], - "sourceType": "module", - "comments": [] -} diff --git a/packages/docgen/test/fixtures/named-import-namespace/code.js b/packages/docgen/test/fixtures/named-import-namespace/code.js deleted file mode 100644 index a6b9234374d42..0000000000000 --- a/packages/docgen/test/fixtures/named-import-namespace/code.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Internal dependencies - */ -import * as variables from './named-import-namespace-module'; - -export { variables }; diff --git a/packages/docgen/test/fixtures/named-import-namespace/exports.json b/packages/docgen/test/fixtures/named-import-namespace/exports.json deleted file mode 100644 index 5350c803aad62..0000000000000 --- a/packages/docgen/test/fixtures/named-import-namespace/exports.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 63, - "end": 84, - "loc": { - "start": { - "line": 3, - "column": 0 - }, - "end": { - "line": 3, - "column": 21 - } - }, - "range": [ 63, 84 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 72, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 18 - } - }, - "range": [ 72, 81 ], - "local": { - "type": "Identifier", - "start": 72, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 18 - } - }, - "range": [ 72, 81 ], - "name": "variables" - }, - "exported": { - "type": "Identifier", - "start": 72, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 18 - } - }, - "range": [ 72, 81 ], - "name": "variables" - } - } - ], - "source": null -} diff --git a/packages/docgen/test/fixtures/named-import-namespace/module-code.js b/packages/docgen/test/fixtures/named-import-namespace/module-code.js deleted file mode 100644 index 5c29fce852840..0000000000000 --- a/packages/docgen/test/fixtures/named-import-namespace/module-code.js +++ /dev/null @@ -1 +0,0 @@ -export { default as controls } from './default-function-named'; diff --git a/packages/docgen/test/fixtures/named-import-namespace/module-exports.json b/packages/docgen/test/fixtures/named-import-namespace/module-exports.json deleted file mode 100644 index b348b28ce8082..0000000000000 --- a/packages/docgen/test/fixtures/named-import-namespace/module-exports.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 0, - "end": 63, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 63 - } - }, - "range": [ 0, 63 ], - "declaration": null, - "specifiers": [ - { - "type": "ExportSpecifier", - "start": 9, - "end": 28, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 28 - } - }, - "range": [ 9, 28 ], - "local": { - "type": "Identifier", - "start": 9, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "range": [ 9, 16 ], - "name": "default" - }, - "exported": { - "type": "Identifier", - "start": 20, - "end": 28, - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 28 - } - }, - "range": [ 20, 28 ], - "name": "controls" - } - } - ], - "source": { - "type": "Literal", - "start": 36, - "end": 62, - "loc": { - "start": { - "line": 1, - "column": 36 - }, - "end": { - "line": 1, - "column": 62 - } - }, - "range": [ 36, 62 ], - "value": "./default-function-named", - "raw": "'./default-function-named'" - } -} diff --git a/packages/docgen/test/fixtures/named-import-namespace/module-ir.json b/packages/docgen/test/fixtures/named-import-namespace/module-ir.json deleted file mode 100644 index 7e2b54e017388..0000000000000 --- a/packages/docgen/test/fixtures/named-import-namespace/module-ir.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "controls", - "description": "Function declaration example.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/named-variable/code.js b/packages/docgen/test/fixtures/named-variable/code.js deleted file mode 100644 index 8b6dce4c578e4..0000000000000 --- a/packages/docgen/test/fixtures/named-variable/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * My declaration example. - */ -export const myDeclaration = true; diff --git a/packages/docgen/test/fixtures/named-variable/exports.json b/packages/docgen/test/fixtures/named-variable/exports.json deleted file mode 100644 index 923791e21608f..0000000000000 --- a/packages/docgen/test/fixtures/named-variable/exports.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 35, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 34 - } - }, - "range": [ 35, 69 ], - "declaration": { - "type": "VariableDeclaration", - "start": 42, - "end": 69, - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 34 - } - }, - "range": [ 42, 69 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 48, - "end": 68, - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 33 - } - }, - "range": [ 48, 68 ], - "id": { - "type": "Identifier", - "start": 48, - "end": 61, - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 26 - } - }, - "range": [ 48, 61 ], - "name": "myDeclaration" - }, - "init": { - "type": "Literal", - "start": 64, - "end": 68, - "loc": { - "start": { - "line": 4, - "column": 29 - }, - "end": { - "line": 4, - "column": 33 - } - }, - "range": [ 64, 68 ], - "value": true, - "raw": "true" - } - } - ], - "kind": "const" - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/named-variables/code.js b/packages/docgen/test/fixtures/named-variables/code.js deleted file mode 100644 index 4f49ac1e883e1..0000000000000 --- a/packages/docgen/test/fixtures/named-variables/code.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * My declaration example. - */ -export const firstDeclaration = true, - secondDeclaration = 42; diff --git a/packages/docgen/test/fixtures/named-variables/exports.json b/packages/docgen/test/fixtures/named-variables/exports.json deleted file mode 100644 index 3f0b18a566431..0000000000000 --- a/packages/docgen/test/fixtures/named-variables/exports.json +++ /dev/null @@ -1,158 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 35, - "end": 97, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 5, - "column": 24 - } - }, - "range": [ 35, 97 ], - "declaration": { - "type": "VariableDeclaration", - "start": 42, - "end": 97, - "loc": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 5, - "column": 24 - } - }, - "range": [ 42, 97 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 48, - "end": 71, - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 36 - } - }, - "range": [ 48, 71 ], - "id": { - "type": "Identifier", - "start": 48, - "end": 64, - "loc": { - "start": { - "line": 4, - "column": 13 - }, - "end": { - "line": 4, - "column": 29 - } - }, - "range": [ 48, 64 ], - "name": "firstDeclaration" - }, - "init": { - "type": "Literal", - "start": 67, - "end": 71, - "loc": { - "start": { - "line": 4, - "column": 32 - }, - "end": { - "line": 4, - "column": 36 - } - }, - "range": [ 67, 71 ], - "value": true, - "raw": "true" - } - }, - { - "type": "VariableDeclarator", - "start": 74, - "end": 96, - "loc": { - "start": { - "line": 5, - "column": 1 - }, - "end": { - "line": 5, - "column": 23 - } - }, - "range": [ 74, 96 ], - "id": { - "type": "Identifier", - "start": 74, - "end": 91, - "loc": { - "start": { - "line": 5, - "column": 1 - }, - "end": { - "line": 5, - "column": 18 - } - }, - "range": [ 74, 91 ], - "name": "secondDeclaration" - }, - "init": { - "type": "Literal", - "start": 94, - "end": 96, - "loc": { - "start": { - "line": 5, - "column": 21 - }, - "end": { - "line": 5, - "column": 23 - } - }, - "range": [ 94, 96 ], - "value": 42, - "raw": "42" - } - } - ], - "kind": "const" - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * My declaration example.\n ", - "start": 0, - "end": 34, - "range": [ 0, 34 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/namespace-commented/code.js b/packages/docgen/test/fixtures/namespace-commented/code.js deleted file mode 100644 index 5008b26d090aa..0000000000000 --- a/packages/docgen/test/fixtures/namespace-commented/code.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This comment should be ignored. - */ -export * from './namespace-module'; diff --git a/packages/docgen/test/fixtures/namespace-commented/exports.json b/packages/docgen/test/fixtures/namespace-commented/exports.json deleted file mode 100644 index e7bd07b8fb378..0000000000000 --- a/packages/docgen/test/fixtures/namespace-commented/exports.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "type": "ExportAllDeclaration", - "start": 43, - "end": 78, - "loc": { - "start": { - "line": 4, - "column": 0 - }, - "end": { - "line": 4, - "column": 35 - } - }, - "range": [ 43, 78 ], - "source": { - "type": "Literal", - "start": 57, - "end": 77, - "loc": { - "start": { - "line": 4, - "column": 14 - }, - "end": { - "line": 4, - "column": 34 - } - }, - "range": [ 57, 77 ], - "value": "./namespace-module", - "raw": "'./namespace-module'" - }, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * This comment should be ignored.\n ", - "start": 0, - "end": 42, - "range": [ 0, 42 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/namespace-commented/module-ir.json b/packages/docgen/test/fixtures/namespace-commented/module-ir.json deleted file mode 100644 index 8e180b80ebdbc..0000000000000 --- a/packages/docgen/test/fixtures/namespace-commented/module-ir.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "name": "default", - "description": "Default variable declaration.", - "tags": [] - }, - { - "name": "MyClass", - "description": "Named class.", - "tags": [] - }, - { - "name": "myFunction", - "description": "Named function.", - "tags": [] - }, - { - "name": "myVariable", - "description": "Named variable.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/namespace-commented/module.js b/packages/docgen/test/fixtures/namespace-commented/module.js deleted file mode 100644 index 1ff51c686236a..0000000000000 --- a/packages/docgen/test/fixtures/namespace-commented/module.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Named variable. - */ -export const myVariable = true; - -/** - * Named function. - */ -export const myFunction = () => {}; - -/** - * Named class. - */ -export class MyClass {} - -/** - * Default variable declaration. - */ -export default 42; diff --git a/packages/docgen/test/fixtures/namespace/code.js b/packages/docgen/test/fixtures/namespace/code.js deleted file mode 100644 index d2705ea5f8e63..0000000000000 --- a/packages/docgen/test/fixtures/namespace/code.js +++ /dev/null @@ -1 +0,0 @@ -export * from './namespace-module'; diff --git a/packages/docgen/test/fixtures/namespace/exports.json b/packages/docgen/test/fixtures/namespace/exports.json deleted file mode 100644 index 1ac85de678c1b..0000000000000 --- a/packages/docgen/test/fixtures/namespace/exports.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "type": "ExportAllDeclaration", - "start": 0, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 35 - } - }, - "range": [ 0, 35 ], - "source": { - "type": "Literal", - "start": 14, - "end": 34, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 34 - } - }, - "range": [ 14, 34 ], - "value": "./namespace-module", - "raw": "'./namespace-module'" - } -} diff --git a/packages/docgen/test/fixtures/namespace/module-ir.json b/packages/docgen/test/fixtures/namespace/module-ir.json deleted file mode 100644 index 8e180b80ebdbc..0000000000000 --- a/packages/docgen/test/fixtures/namespace/module-ir.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "name": "default", - "description": "Default variable declaration.", - "tags": [] - }, - { - "name": "MyClass", - "description": "Named class.", - "tags": [] - }, - { - "name": "myFunction", - "description": "Named function.", - "tags": [] - }, - { - "name": "myVariable", - "description": "Named variable.", - "tags": [] - } -] diff --git a/packages/docgen/test/fixtures/namespace/module.js b/packages/docgen/test/fixtures/namespace/module.js deleted file mode 100644 index 1ff51c686236a..0000000000000 --- a/packages/docgen/test/fixtures/namespace/module.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Named variable. - */ -export const myVariable = true; - -/** - * Named function. - */ -export const myFunction = () => {}; - -/** - * Named class. - */ -export class MyClass {} - -/** - * Default variable declaration. - */ -export default 42; diff --git a/packages/docgen/test/fixtures/tags-function/code.js b/packages/docgen/test/fixtures/tags-function/code.js deleted file mode 100644 index 00b529b8691f3..0000000000000 --- a/packages/docgen/test/fixtures/tags-function/code.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * A function that adds two parameters. - * - * @deprecated Use native addition instead. - * @since 2.0.0 - * - * @see addition - * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators - * - * @param {number} firstParam The first param to add. - * @param {number} secondParam The second param to add. - * - * @example - * - * ```js - * const addResult = sum( 1, 3 ); - * console.log( addResult ); // will yield 4 - * ``` - * - * @return {number} The result of adding the two params. - */ -export const sum = ( firstParam, secondParam ) => { - return firstParam + secondParam; -}; diff --git a/packages/docgen/test/fixtures/tags-function/exports.json b/packages/docgen/test/fixtures/tags-function/exports.json deleted file mode 100644 index b852739bd8d8e..0000000000000 --- a/packages/docgen/test/fixtures/tags-function/exports.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 521, - "end": 609, - "loc": { - "start": { - "line": 22, - "column": 0 - }, - "end": { - "line": 24, - "column": 2 - } - }, - "range": [ 521, 609 ], - "declaration": { - "type": "VariableDeclaration", - "start": 528, - "end": 609, - "loc": { - "start": { - "line": 22, - "column": 7 - }, - "end": { - "line": 24, - "column": 2 - } - }, - "range": [ 528, 609 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 534, - "end": 608, - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 24, - "column": 1 - } - }, - "range": [ 534, 608 ], - "id": { - "type": "Identifier", - "start": 534, - "end": 537, - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 22, - "column": 16 - } - }, - "range": [ 534, 537 ], - "name": "sum" - }, - "init": { - "type": "ArrowFunctionExpression", - "start": 540, - "end": 608, - "loc": { - "start": { - "line": 22, - "column": 19 - }, - "end": { - "line": 24, - "column": 1 - } - }, - "range": [ 540, 608 ], - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 542, - "end": 552, - "loc": { - "start": { - "line": 22, - "column": 21 - }, - "end": { - "line": 22, - "column": 31 - } - }, - "range": [ 542, 552 ], - "name": "firstParam" - }, - { - "type": "Identifier", - "start": 554, - "end": 565, - "loc": { - "start": { - "line": 22, - "column": 33 - }, - "end": { - "line": 22, - "column": 44 - } - }, - "range": [ 554, 565 ], - "name": "secondParam" - } - ], - "body": { - "type": "BlockStatement", - "start": 571, - "end": 608, - "loc": { - "start": { - "line": 22, - "column": 50 - }, - "end": { - "line": 24, - "column": 1 - } - }, - "range": [ 571, 608 ], - "body": [ - { - "type": "ReturnStatement", - "start": 574, - "end": 606, - "loc": { - "start": { - "line": 23, - "column": 1 - }, - "end": { - "line": 23, - "column": 33 - } - }, - "range": [ 574, 606 ], - "argument": { - "type": "BinaryExpression", - "start": 581, - "end": 605, - "loc": { - "start": { - "line": 23, - "column": 8 - }, - "end": { - "line": 23, - "column": 32 - } - }, - "range": [ 581, 605 ], - "left": { - "type": "Identifier", - "start": 581, - "end": 591, - "loc": { - "start": { - "line": 23, - "column": 8 - }, - "end": { - "line": 23, - "column": 18 - } - }, - "range": [ 581, 591 ], - "name": "firstParam" - }, - "operator": "+", - "right": { - "type": "Identifier", - "start": 594, - "end": 605, - "loc": { - "start": { - "line": 23, - "column": 21 - }, - "end": { - "line": 23, - "column": 32 - } - }, - "range": [ 594, 605 ], - "name": "secondParam" - } - } - } - ] - } - } - } - ], - "kind": "const" - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * A function that adds two parameters.\n *\n * @deprecated Use native addition instead.\n * @since v2\n *\n * @see addition\n * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators\n *\n * @param {number} firstParam The first param to add.\n * @param {number} secondParam The second param to add.\n *\n * @example\n *\n * ```js\n * const addResult = sum( 1, 3 );\n * console.log( addResult ); // will yield 4\n * ```\n *\n * @return {number} The result of adding the two params.\n ", - "start": 0, - "end": 520, - "range": [ 0, 520 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 21, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/tags-variable/code.js b/packages/docgen/test/fixtures/tags-variable/code.js deleted file mode 100644 index d2d32717a67bc..0000000000000 --- a/packages/docgen/test/fixtures/tags-variable/code.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Constant to document the meaning of life, - * the universe and everything else. - * - * @type {number} - */ -export const THE_MEANING = 42; diff --git a/packages/docgen/test/fixtures/tags-variable/exports.json b/packages/docgen/test/fixtures/tags-variable/exports.json deleted file mode 100644 index 1c31fb3c9ee82..0000000000000 --- a/packages/docgen/test/fixtures/tags-variable/exports.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "type": "ExportNamedDeclaration", - "start": 111, - "end": 141, - "loc": { - "start": { - "line": 7, - "column": 0 - }, - "end": { - "line": 7, - "column": 30 - } - }, - "range": [ 111, 141 ], - "declaration": { - "type": "VariableDeclaration", - "start": 118, - "end": 141, - "loc": { - "start": { - "line": 7, - "column": 7 - }, - "end": { - "line": 7, - "column": 30 - } - }, - "range": [ 118, 141 ], - "declarations": [ - { - "type": "VariableDeclarator", - "start": 124, - "end": 140, - "loc": { - "start": { - "line": 7, - "column": 13 - }, - "end": { - "line": 7, - "column": 29 - } - }, - "range": [ 124, 140 ], - "id": { - "type": "Identifier", - "start": 124, - "end": 135, - "loc": { - "start": { - "line": 7, - "column": 13 - }, - "end": { - "line": 7, - "column": 24 - } - }, - "range": [ 124, 135 ], - "name": "THE_MEANING" - }, - "init": { - "type": "Literal", - "start": 138, - "end": 140, - "loc": { - "start": { - "line": 7, - "column": 27 - }, - "end": { - "line": 7, - "column": 29 - } - }, - "range": [ 138, 140 ], - "value": 42, - "raw": "42" - } - } - ], - "kind": "const" - }, - "specifiers": [], - "source": null, - "leadingComments": [ - { - "type": "Block", - "value": "*\n * Constant to document the meaning of life,\n * the universe and everything else.\n *\n * @type {number}\n ", - "start": 0, - "end": 110, - "range": [ 0, 110 ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 6, - "column": 3 - } - } - } - ] -} diff --git a/packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/example.ts b/packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/example.ts deleted file mode 100644 index d8112a5276b85..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -function fn( [ first, second ]: ( T & S ) | V ): S { - return second; -} diff --git a/packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/get-node.js b/packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/get-node.js deleted file mode 100644 index 505093910f614..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/array-destructuring-any-other-type/get-node.js +++ /dev/null @@ -1,363 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 74, - end: 144, - loc: { - start: { - line: 7, - column: 0, - }, - end: { - line: 9, - column: 1, - }, - }, - leadingComments: [ - { - type: 'CommentBlock', - value: - '*\n * @param param0\n * @param param0.0\n * @param param0.1\n * @return\n ', - start: 0, - end: 73, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 6, - column: 3, - }, - }, - }, - ], - id: { - type: 'Identifier', - start: 83, - end: 85, - loc: { - start: { - line: 7, - column: 9, - }, - end: { - line: 7, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'ArrayPattern', - start: 87, - end: 119, - loc: { - start: { - line: 7, - column: 13, - }, - end: { - line: 7, - column: 45, - }, - }, - elements: [ - { - type: 'Identifier', - start: 89, - end: 94, - loc: { - start: { - line: 7, - column: 15, - }, - end: { - line: 7, - column: 20, - }, - identifierName: 'first', - }, - name: 'first', - }, - { - type: 'Identifier', - start: 96, - end: 102, - loc: { - start: { - line: 7, - column: 22, - }, - end: { - line: 7, - column: 28, - }, - identifierName: 'second', - }, - name: 'second', - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 104, - end: 119, - loc: { - start: { - line: 7, - column: 30, - }, - end: { - line: 7, - column: 45, - }, - }, - typeAnnotation: { - type: 'TSUnionType', - start: 106, - end: 119, - loc: { - start: { - line: 7, - column: 32, - }, - end: { - line: 7, - column: 45, - }, - }, - types: [ - { - type: 'TSParenthesizedType', - start: 106, - end: 115, - loc: { - start: { - line: 7, - column: 32, - }, - end: { - line: 7, - column: 41, - }, - }, - typeAnnotation: { - type: 'TSIntersectionType', - start: 108, - end: 113, - loc: { - start: { - line: 7, - column: 34, - }, - end: { - line: 7, - column: 39, - }, - }, - types: [ - { - type: 'TSTypeReference', - start: 108, - end: 109, - loc: { - start: { - line: 7, - column: 34, - }, - end: { - line: 7, - column: 35, - }, - }, - typeName: { - type: 'Identifier', - start: 108, - end: 109, - loc: { - start: { - line: 7, - column: 34, - }, - end: { - line: 7, - column: 35, - }, - identifierName: 'T', - }, - name: 'T', - }, - }, - { - type: 'TSTypeReference', - start: 112, - end: 113, - loc: { - start: { - line: 7, - column: 38, - }, - end: { - line: 7, - column: 39, - }, - }, - typeName: { - type: 'Identifier', - start: 112, - end: 113, - loc: { - start: { - line: 7, - column: 38, - }, - end: { - line: 7, - column: 39, - }, - identifierName: 'S', - }, - name: 'S', - }, - }, - ], - }, - }, - { - type: 'TSTypeReference', - start: 118, - end: 119, - loc: { - start: { - line: 7, - column: 44, - }, - end: { - line: 7, - column: 45, - }, - }, - typeName: { - type: 'Identifier', - start: 118, - end: 119, - loc: { - start: { - line: 7, - column: 44, - }, - end: { - line: 7, - column: 45, - }, - identifierName: 'V', - }, - name: 'V', - }, - }, - ], - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 121, - end: 124, - loc: { - start: { - line: 7, - column: 47, - }, - end: { - line: 7, - column: 50, - }, - }, - typeAnnotation: { - type: 'TSTypeReference', - start: 123, - end: 124, - loc: { - start: { - line: 7, - column: 49, - }, - end: { - line: 7, - column: 50, - }, - }, - typeName: { - type: 'Identifier', - start: 123, - end: 124, - loc: { - start: { - line: 7, - column: 49, - }, - end: { - line: 7, - column: 50, - }, - identifierName: 'S', - }, - name: 'S', - }, - }, - }, - body: { - type: 'BlockStatement', - start: 125, - end: 144, - loc: { - start: { - line: 7, - column: 51, - }, - end: { - line: 9, - column: 1, - }, - }, - body: [ - { - type: 'ReturnStatement', - start: 128, - end: 142, - loc: { - start: { - line: 8, - column: 1, - }, - end: { - line: 8, - column: 15, - }, - }, - argument: { - type: 'Identifier', - start: 135, - end: 141, - loc: { - start: { - line: 8, - column: 8, - }, - end: { - line: 8, - column: 14, - }, - identifierName: 'second', - }, - name: 'second', - }, - }, - ], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/example.ts b/packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/example.ts deleted file mode 100644 index c0c95f56c5b20..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -function fn< T >( [ head ]: T[] ): T { - return head; -} diff --git a/packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/get-node.js b/packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/get-node.js deleted file mode 100644 index 0ef13ed8cd84c..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/array-destructuring-array-type/get-node.js +++ /dev/null @@ -1,281 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 88, - end: 142, - loc: { - start: { - line: 6, - column: 0, - }, - end: { - line: 8, - column: 1, - }, - }, - leadingComments: [ - { - type: 'CommentBlock', - value: - '*\n * @param foo Array.\n * @param foo.0 The first foo.\n * @return The head of foo.\n ', - start: 0, - end: 87, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 5, - column: 3, - }, - }, - }, - ], - id: { - type: 'Identifier', - start: 97, - end: 99, - loc: { - start: { - line: 6, - column: 9, - }, - end: { - line: 6, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - typeParameters: { - type: 'TSTypeParameterDeclaration', - start: 99, - end: 104, - loc: { - start: { - line: 6, - column: 11, - }, - end: { - line: 6, - column: 16, - }, - }, - params: [ - { - type: 'TSTypeParameter', - start: 101, - end: 102, - loc: { - start: { - line: 6, - column: 13, - }, - end: { - line: 6, - column: 14, - }, - }, - name: 'T', - }, - ], - }, - params: [ - { - type: 'ArrayPattern', - start: 106, - end: 119, - loc: { - start: { - line: 6, - column: 18, - }, - end: { - line: 6, - column: 31, - }, - }, - elements: [ - { - type: 'Identifier', - start: 108, - end: 112, - loc: { - start: { - line: 6, - column: 20, - }, - end: { - line: 6, - column: 24, - }, - identifierName: 'head', - }, - name: 'head', - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 114, - end: 119, - loc: { - start: { - line: 6, - column: 26, - }, - end: { - line: 6, - column: 31, - }, - }, - typeAnnotation: { - type: 'TSArrayType', - start: 116, - end: 119, - loc: { - start: { - line: 6, - column: 28, - }, - end: { - line: 6, - column: 31, - }, - }, - elementType: { - type: 'TSTypeReference', - start: 116, - end: 117, - loc: { - start: { - line: 6, - column: 28, - }, - end: { - line: 6, - column: 29, - }, - }, - typeName: { - type: 'Identifier', - start: 116, - end: 117, - loc: { - start: { - line: 6, - column: 28, - }, - end: { - line: 6, - column: 29, - }, - identifierName: 'T', - }, - name: 'T', - }, - }, - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 121, - end: 124, - loc: { - start: { - line: 6, - column: 33, - }, - end: { - line: 6, - column: 36, - }, - }, - typeAnnotation: { - type: 'TSTypeReference', - start: 123, - end: 124, - loc: { - start: { - line: 6, - column: 35, - }, - end: { - line: 6, - column: 36, - }, - }, - typeName: { - type: 'Identifier', - start: 123, - end: 124, - loc: { - start: { - line: 6, - column: 35, - }, - end: { - line: 6, - column: 36, - }, - identifierName: 'T', - }, - name: 'T', - }, - }, - }, - body: { - type: 'BlockStatement', - start: 125, - end: 142, - loc: { - start: { - line: 6, - column: 37, - }, - end: { - line: 8, - column: 1, - }, - }, - body: [ - { - type: 'ReturnStatement', - start: 128, - end: 140, - loc: { - start: { - line: 7, - column: 1, - }, - end: { - line: 7, - column: 13, - }, - }, - argument: { - type: 'Identifier', - start: 135, - end: 139, - loc: { - start: { - line: 7, - column: 8, - }, - end: { - line: 7, - column: 12, - }, - identifierName: 'head', - }, - name: 'head', - }, - }, - ], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/example.ts b/packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/example.ts deleted file mode 100644 index d1685491bb53f..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -function second< T, S = T >( [ head, sec ]: [ T, S ] ): S { - return sec; -} diff --git a/packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/get-node.js b/packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/get-node.js deleted file mode 100644 index 5c817cc834d72..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/array-destructuring-tuple-type/get-node.js +++ /dev/null @@ -1,380 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 120, - end: 194, - loc: { - start: { - line: 7, - column: 0, - }, - end: { - line: 9, - column: 1, - }, - }, - leadingComments: [ - { - type: 'CommentBlock', - value: - '*\n * @param foo Array.\n * @param foo.0 The first foo.\n * @param foo.1 The second foo.\n * @return The head of foo.\n ', - start: 0, - end: 119, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 6, - column: 3, - }, - }, - }, - ], - id: { - type: 'Identifier', - start: 129, - end: 135, - loc: { - start: { - line: 7, - column: 9, - }, - end: { - line: 7, - column: 15, - }, - identifierName: 'second', - }, - name: 'second', - }, - generator: false, - async: false, - typeParameters: { - type: 'TSTypeParameterDeclaration', - start: 135, - end: 147, - loc: { - start: { - line: 7, - column: 15, - }, - end: { - line: 7, - column: 27, - }, - }, - params: [ - { - type: 'TSTypeParameter', - start: 137, - end: 138, - loc: { - start: { - line: 7, - column: 17, - }, - end: { - line: 7, - column: 18, - }, - }, - name: 'T', - }, - { - type: 'TSTypeParameter', - start: 140, - end: 145, - loc: { - start: { - line: 7, - column: 20, - }, - end: { - line: 7, - column: 25, - }, - }, - name: 'S', - default: { - type: 'TSTypeReference', - start: 144, - end: 145, - loc: { - start: { - line: 7, - column: 24, - }, - end: { - line: 7, - column: 25, - }, - }, - typeName: { - type: 'Identifier', - start: 144, - end: 145, - loc: { - start: { - line: 7, - column: 24, - }, - end: { - line: 7, - column: 25, - }, - identifierName: 'T', - }, - name: 'T', - }, - }, - }, - ], - }, - params: [ - { - type: 'ArrayPattern', - start: 149, - end: 172, - loc: { - start: { - line: 7, - column: 29, - }, - end: { - line: 7, - column: 52, - }, - }, - elements: [ - { - type: 'Identifier', - start: 151, - end: 155, - loc: { - start: { - line: 7, - column: 31, - }, - end: { - line: 7, - column: 35, - }, - identifierName: 'head', - }, - name: 'head', - }, - { - type: 'Identifier', - start: 157, - end: 160, - loc: { - start: { - line: 7, - column: 37, - }, - end: { - line: 7, - column: 40, - }, - identifierName: 'sec', - }, - name: 'sec', - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 162, - end: 172, - loc: { - start: { - line: 7, - column: 42, - }, - end: { - line: 7, - column: 52, - }, - }, - typeAnnotation: { - type: 'TSTupleType', - start: 164, - end: 172, - loc: { - start: { - line: 7, - column: 44, - }, - end: { - line: 7, - column: 52, - }, - }, - elementTypes: [ - { - type: 'TSTypeReference', - start: 166, - end: 167, - loc: { - start: { - line: 7, - column: 46, - }, - end: { - line: 7, - column: 47, - }, - }, - typeName: { - type: 'Identifier', - start: 166, - end: 167, - loc: { - start: { - line: 7, - column: 46, - }, - end: { - line: 7, - column: 47, - }, - identifierName: 'T', - }, - name: 'T', - }, - }, - { - type: 'TSTypeReference', - start: 169, - end: 170, - loc: { - start: { - line: 7, - column: 49, - }, - end: { - line: 7, - column: 50, - }, - }, - typeName: { - type: 'Identifier', - start: 169, - end: 170, - loc: { - start: { - line: 7, - column: 49, - }, - end: { - line: 7, - column: 50, - }, - identifierName: 'S', - }, - name: 'S', - }, - }, - ], - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 174, - end: 177, - loc: { - start: { - line: 7, - column: 54, - }, - end: { - line: 7, - column: 57, - }, - }, - typeAnnotation: { - type: 'TSTypeReference', - start: 176, - end: 177, - loc: { - start: { - line: 7, - column: 56, - }, - end: { - line: 7, - column: 57, - }, - }, - typeName: { - type: 'Identifier', - start: 176, - end: 177, - loc: { - start: { - line: 7, - column: 56, - }, - end: { - line: 7, - column: 57, - }, - identifierName: 'S', - }, - name: 'S', - }, - }, - }, - body: { - type: 'BlockStatement', - start: 178, - end: 194, - loc: { - start: { - line: 7, - column: 58, - }, - end: { - line: 9, - column: 1, - }, - }, - body: [ - { - type: 'ReturnStatement', - start: 181, - end: 192, - loc: { - start: { - line: 8, - column: 1, - }, - end: { - line: 8, - column: 12, - }, - }, - argument: { - type: 'Identifier', - start: 188, - end: 191, - loc: { - start: { - line: 8, - column: 8, - }, - end: { - line: 8, - column: 11, - }, - identifierName: 'sec', - }, - name: 'sec', - }, - }, - ], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/example.ts b/packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/example.ts deleted file mode 100644 index 3e3b95f11c750..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -type MyType< T > = {}; -function fn( foo: MyType< string | number >[] ): MyType< string & number >[] { - return []; -} diff --git a/packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/get-node.js b/packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/get-node.js deleted file mode 100644 index 0e057e8ea68e2..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/arrays-generic-types-unions-intersections/get-node.js +++ /dev/null @@ -1,98 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - id: { - type: 'Identifier', - name: 'fn', - range: [ 31, 33 ], - }, - generator: false, - expression: false, - async: false, - params: [ - { - type: 'Identifier', - name: 'foo', - range: [ 34, 62 ], - typeAnnotation: { - type: 'TSTypeAnnotation', - range: [ 37, 62 ], - typeAnnotation: { - type: 'TSArrayType', - elementType: { - type: 'TSTypeReference', - typeName: { - type: 'Identifier', - name: 'MyType', - range: [ 39, 45 ], - }, - typeParameters: { - type: 'TSTypeParameterInstantiation', - range: [ 45, 60 ], - params: [ - { - type: 'TSUnionType', - types: [ - { - type: 'TSStringKeyword', - range: [ 46, 52 ], - }, - { - type: 'TSNumberKeyword', - range: [ 53, 59 ], - }, - ], - range: [ 46, 59 ], - }, - ], - }, - range: [ 39, 60 ], - }, - range: [ 39, 62 ], - }, - }, - }, - ], - body: { - type: 'BlockStatement', - body: [], - range: [ 89, 91 ], - }, - range: [ 22, 91 ], - returnType: { - type: 'TSTypeAnnotation', - range: [ 63, 88 ], - typeAnnotation: { - type: 'TSArrayType', - elementType: { - type: 'TSTypeReference', - typeName: { - type: 'Identifier', - name: 'MyType', - range: [ 65, 71 ], - }, - typeParameters: { - type: 'TSTypeParameterInstantiation', - range: [ 71, 86 ], - params: [ - { - type: 'TSIntersectionType', - types: [ - { - type: 'TSStringKeyword', - range: [ 72, 78 ], - }, - { - type: 'TSNumberKeyword', - range: [ 79, 85 ], - }, - ], - range: [ 72, 85 ], - }, - ], - }, - range: [ 65, 86 ], - }, - range: [ 65, 88 ], - }, - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/arrow-function/example.ts b/packages/docgen/test/fixtures/type-annotations/arrow-function/example.ts deleted file mode 100644 index d3363c20350c5..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/arrow-function/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const fn = ( - callback: ( foo: string, ...rest: any[] ) => GenericType< T > -): void => {}; diff --git a/packages/docgen/test/fixtures/type-annotations/arrow-function/get-node.js b/packages/docgen/test/fixtures/type-annotations/arrow-function/get-node.js deleted file mode 100644 index 9120a2c43a636..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/arrow-function/get-node.js +++ /dev/null @@ -1,407 +0,0 @@ -module.exports = () => ( { - type: 'ExportNamedDeclaration', - start: 0, - end: 97, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 3, - column: 14, - }, - }, - exportKind: 'value', - specifiers: [], - source: null, - declaration: { - type: 'VariableDeclaration', - start: 7, - end: 97, - loc: { - start: { - line: 1, - column: 7, - }, - end: { - line: 3, - column: 14, - }, - }, - declarations: [ - { - type: 'VariableDeclarator', - start: 13, - end: 96, - loc: { - start: { - line: 1, - column: 13, - }, - end: { - line: 3, - column: 13, - }, - }, - id: { - type: 'Identifier', - start: 13, - end: 15, - loc: { - start: { - line: 1, - column: 13, - }, - end: { - line: 1, - column: 15, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - init: { - type: 'ArrowFunctionExpression', - start: 18, - end: 96, - loc: { - start: { - line: 1, - column: 18, - }, - end: { - line: 3, - column: 13, - }, - }, - returnType: { - type: 'TSTypeAnnotation', - start: 84, - end: 90, - loc: { - start: { - line: 3, - column: 1, - }, - end: { - line: 3, - column: 7, - }, - }, - typeAnnotation: { - type: 'TSVoidKeyword', - start: 86, - end: 90, - loc: { - start: { - line: 3, - column: 3, - }, - end: { - line: 3, - column: 7, - }, - }, - }, - }, - id: null, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 21, - end: 82, - loc: { - start: { - line: 2, - column: 1, - }, - end: { - line: 2, - column: 62, - }, - identifierName: 'callback', - }, - name: 'callback', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 29, - end: 82, - loc: { - start: { - line: 2, - column: 9, - }, - end: { - line: 2, - column: 62, - }, - }, - typeAnnotation: { - type: 'TSFunctionType', - start: 31, - end: 82, - loc: { - start: { - line: 2, - column: 11, - }, - end: { - line: 2, - column: 62, - }, - }, - parameters: [ - { - type: 'Identifier', - start: 33, - end: 44, - loc: { - start: { - line: 2, - column: 13, - }, - end: { - line: 2, - column: 24, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 36, - end: 44, - loc: { - start: { - line: 2, - column: 16, - }, - end: { - line: 2, - column: 24, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 38, - end: 44, - loc: { - start: { - line: 2, - column: 18, - }, - end: { - line: 2, - column: 24, - }, - }, - }, - }, - }, - { - type: 'RestElement', - start: 46, - end: 60, - loc: { - start: { - line: 2, - column: 26, - }, - end: { - line: 2, - column: 40, - }, - }, - argument: { - type: 'Identifier', - start: 49, - end: 53, - loc: { - start: { - line: 2, - column: 29, - }, - end: { - line: 2, - column: 33, - }, - identifierName: 'rest', - }, - name: 'rest', - }, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 53, - end: 60, - loc: { - start: { - line: 2, - column: 33, - }, - end: { - line: 2, - column: 40, - }, - }, - typeAnnotation: { - type: 'TSArrayType', - start: 55, - end: 60, - loc: { - start: { - line: 2, - column: 35, - }, - end: { - line: 2, - column: 40, - }, - }, - elementType: { - type: 'TSAnyKeyword', - start: 55, - end: 58, - loc: { - start: { - line: 2, - column: 35, - }, - end: { - line: 2, - column: 38, - }, - }, - }, - }, - }, - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 63, - end: 82, - loc: { - start: { - line: 2, - column: 43, - }, - end: { - line: 2, - column: 62, - }, - }, - typeAnnotation: { - type: 'TSTypeReference', - start: 66, - end: 82, - loc: { - start: { - line: 2, - column: 46, - }, - end: { - line: 2, - column: 62, - }, - }, - typeName: { - type: 'Identifier', - start: 66, - end: 77, - loc: { - start: { - line: 2, - column: 46, - }, - end: { - line: 2, - column: 57, - }, - identifierName: - 'GenericType', - }, - name: 'GenericType', - }, - typeParameters: { - type: - 'TSTypeParameterInstantiation', - start: 77, - end: 82, - loc: { - start: { - line: 2, - column: 57, - }, - end: { - line: 2, - column: 62, - }, - }, - params: [ - { - type: 'TSTypeReference', - start: 79, - end: 80, - loc: { - start: { - line: 2, - column: 59, - }, - end: { - line: 2, - column: 60, - }, - }, - typeName: { - type: 'Identifier', - start: 79, - end: 80, - loc: { - start: { - line: 2, - column: 59, - }, - end: { - line: 2, - column: 60, - }, - identifierName: - 'T', - }, - name: 'T', - }, - }, - ], - }, - }, - }, - }, - }, - }, - ], - body: { - type: 'BlockStatement', - start: 94, - end: 96, - loc: { - start: { - line: 3, - column: 11, - }, - end: { - line: 3, - column: 13, - }, - }, - body: [], - directives: [], - }, - }, - }, - ], - kind: 'const', - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/assignment-pattern/example.ts b/packages/docgen/test/fixtures/type-annotations/assignment-pattern/example.ts deleted file mode 100644 index 15bd2a49cad22..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/assignment-pattern/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -function fn( [ foo ]: string = '' ): string { - return foo; -} diff --git a/packages/docgen/test/fixtures/type-annotations/assignment-pattern/get-node.js b/packages/docgen/test/fixtures/type-annotations/assignment-pattern/get-node.js deleted file mode 100644 index b48535c19c28f..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/assignment-pattern/get-node.js +++ /dev/null @@ -1,233 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 55, - end: 115, - loc: { - start: { - line: 6, - column: 0, - }, - end: { - line: 8, - column: 1, - }, - }, - leadingComments: [ - { - type: 'CommentBlock', - value: '*\n * @param param0\n * @param param0.0\n * @return\n ', - start: 0, - end: 54, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 5, - column: 3, - }, - }, - }, - ], - id: { - type: 'Identifier', - start: 64, - end: 66, - loc: { - start: { - line: 6, - column: 9, - }, - end: { - line: 6, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'AssignmentPattern', - start: 68, - end: 88, - loc: { - start: { - line: 6, - column: 13, - }, - end: { - line: 6, - column: 33, - }, - }, - left: { - type: 'ArrayPattern', - start: 68, - end: 83, - loc: { - start: { - line: 6, - column: 13, - }, - end: { - line: 6, - column: 28, - }, - }, - elements: [ - { - type: 'Identifier', - start: 70, - end: 73, - loc: { - start: { - line: 6, - column: 15, - }, - end: { - line: 6, - column: 18, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 75, - end: 83, - loc: { - start: { - line: 6, - column: 20, - }, - end: { - line: 6, - column: 28, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 77, - end: 83, - loc: { - start: { - line: 6, - column: 22, - }, - end: { - line: 6, - column: 28, - }, - }, - }, - }, - }, - right: { - type: 'StringLiteral', - start: 86, - end: 88, - loc: { - start: { - line: 6, - column: 31, - }, - end: { - line: 6, - column: 33, - }, - }, - extra: { - rawValue: '', - raw: "''", - }, - value: '', - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 90, - end: 98, - loc: { - start: { - line: 6, - column: 35, - }, - end: { - line: 6, - column: 43, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 92, - end: 98, - loc: { - start: { - line: 6, - column: 37, - }, - end: { - line: 6, - column: 43, - }, - }, - }, - }, - body: { - type: 'BlockStatement', - start: 99, - end: 115, - loc: { - start: { - line: 6, - column: 44, - }, - end: { - line: 8, - column: 1, - }, - }, - body: [ - { - type: 'ReturnStatement', - start: 102, - end: 113, - loc: { - start: { - line: 7, - column: 1, - }, - end: { - line: 7, - column: 12, - }, - }, - argument: { - type: 'Identifier', - start: 109, - end: 112, - loc: { - start: { - line: 7, - column: 8, - }, - end: { - line: 7, - column: 11, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - }, - ], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/example.ts b/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/example.ts deleted file mode 100644 index 4512d8c2f1c44..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This is a description of the variable - */ -export const foo: ( string | number )[] = []; diff --git a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/get-node.js b/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/get-node.js deleted file mode 100644 index b5ef9c3c9438a..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration-statics/get-node.js +++ /dev/null @@ -1,194 +0,0 @@ -module.exports = () => ( { - type: 'ExportNamedDeclaration', - start: 49, - end: 94, - loc: { - start: { - line: 4, - column: 0, - }, - end: { - line: 4, - column: 45, - }, - }, - leadingComments: [ - { - type: 'CommentBlock', - value: '*\n * This is a description of the variable\n ', - start: 0, - end: 48, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 3, - column: 3, - }, - }, - }, - ], - exportKind: 'value', - specifiers: [], - source: null, - declaration: { - type: 'VariableDeclaration', - start: 56, - end: 94, - loc: { - start: { - line: 4, - column: 7, - }, - end: { - line: 4, - column: 45, - }, - }, - declarations: [ - { - type: 'VariableDeclarator', - start: 62, - end: 93, - loc: { - start: { - line: 4, - column: 13, - }, - end: { - line: 4, - column: 44, - }, - }, - id: { - type: 'Identifier', - start: 62, - end: 88, - loc: { - start: { - line: 4, - column: 13, - }, - end: { - line: 4, - column: 39, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 65, - end: 88, - loc: { - start: { - line: 4, - column: 16, - }, - end: { - line: 4, - column: 39, - }, - }, - typeAnnotation: { - type: 'TSArrayType', - start: 67, - end: 88, - loc: { - start: { - line: 4, - column: 18, - }, - end: { - line: 4, - column: 39, - }, - }, - elementType: { - type: 'TSParenthesizedType', - start: 67, - end: 86, - loc: { - start: { - line: 4, - column: 18, - }, - end: { - line: 4, - column: 37, - }, - }, - typeAnnotation: { - type: 'TSUnionType', - start: 69, - end: 84, - loc: { - start: { - line: 4, - column: 20, - }, - end: { - line: 4, - column: 35, - }, - }, - types: [ - { - type: 'TSStringKeyword', - start: 69, - end: 75, - loc: { - start: { - line: 4, - column: 20, - }, - end: { - line: 4, - column: 26, - }, - }, - }, - { - type: 'TSNumberKeyword', - start: 78, - end: 84, - loc: { - start: { - line: 4, - column: 29, - }, - end: { - line: 4, - column: 35, - }, - }, - }, - ], - }, - }, - }, - }, - }, - init: { - type: 'ArrayExpression', - start: 91, - end: 93, - loc: { - start: { - line: 4, - column: 42, - }, - end: { - line: 4, - column: 44, - }, - }, - elements: [], - }, - }, - ], - kind: 'const', - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/example.ts b/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/example.ts deleted file mode 100644 index 0390bd66739b8..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/example.ts +++ /dev/null @@ -1 +0,0 @@ -export const fn = ( foo: string ): void => {}; diff --git a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/get-node.js b/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/get-node.js deleted file mode 100644 index 7fe1ae4ece6bd..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/exported-variable-declaration/get-node.js +++ /dev/null @@ -1,182 +0,0 @@ -module.exports = () => ( { - type: 'ExportNamedDeclaration', - start: 0, - end: 43, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 1, - column: 43, - }, - }, - exportKind: 'value', - specifiers: [], - source: null, - declaration: { - type: 'VariableDeclaration', - start: 7, - end: 43, - loc: { - start: { - line: 1, - column: 7, - }, - end: { - line: 1, - column: 43, - }, - }, - declarations: [ - { - type: 'VariableDeclarator', - start: 13, - end: 43, - loc: { - start: { - line: 1, - column: 13, - }, - end: { - line: 1, - column: 43, - }, - }, - id: { - type: 'Identifier', - start: 13, - end: 15, - loc: { - start: { - line: 1, - column: 13, - }, - end: { - line: 1, - column: 15, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - init: { - type: 'ArrowFunctionExpression', - start: 18, - end: 43, - loc: { - start: { - line: 1, - column: 18, - }, - end: { - line: 1, - column: 43, - }, - }, - returnType: { - type: 'TSTypeAnnotation', - start: 31, - end: 37, - loc: { - start: { - line: 1, - column: 31, - }, - end: { - line: 1, - column: 37, - }, - }, - typeAnnotation: { - type: 'TSVoidKeyword', - start: 33, - end: 37, - loc: { - start: { - line: 1, - column: 33, - }, - end: { - line: 1, - column: 37, - }, - }, - }, - }, - id: null, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 19, - end: 30, - loc: { - start: { - line: 1, - column: 19, - }, - end: { - line: 1, - column: 30, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 22, - end: 30, - loc: { - start: { - line: 1, - column: 22, - }, - end: { - line: 1, - column: 30, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 24, - end: 30, - loc: { - start: { - line: 1, - column: 24, - }, - end: { - line: 1, - column: 30, - }, - }, - }, - }, - }, - ], - body: { - type: 'BlockStatement', - start: 41, - end: 43, - loc: { - start: { - line: 1, - column: 41, - }, - end: { - line: 1, - column: 43, - }, - }, - body: [], - directives: [], - }, - }, - }, - ], - kind: 'const', - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/example.ts b/packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/example.ts deleted file mode 100644 index d1b83b3cad7c9..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -function fn( - foo: import('react').bar.baz.types.ComponentType[ 'displayName' ], - ...rest: [ string | number, ...( keyof constant ) ] -): foo is string {} diff --git a/packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/get-node.js b/packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/get-node.js deleted file mode 100644 index 99f409d6ca63b..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/get-node.js +++ /dev/null @@ -1,550 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 0, - end: 153, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 4, - column: 19, - }, - }, - id: { - type: 'Identifier', - start: 9, - end: 11, - loc: { - start: { - line: 1, - column: 9, - }, - end: { - line: 1, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 14, - end: 79, - loc: { - start: { - line: 2, - column: 1, - }, - end: { - line: 2, - column: 66, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 17, - end: 79, - loc: { - start: { - line: 2, - column: 4, - }, - end: { - line: 2, - column: 66, - }, - }, - typeAnnotation: { - type: 'TSIndexedAccessType', - start: 19, - end: 79, - loc: { - start: { - line: 2, - column: 6, - }, - end: { - line: 2, - column: 66, - }, - }, - objectType: { - type: 'TSImportType', - start: 19, - end: 62, - loc: { - start: { - line: 2, - column: 6, - }, - end: { - line: 2, - column: 49, - }, - }, - argument: { - type: 'StringLiteral', - start: 26, - end: 33, - loc: { - start: { - line: 2, - column: 13, - }, - end: { - line: 2, - column: 20, - }, - }, - extra: { - rawValue: 'react', - raw: "'react'", - }, - value: 'react', - }, - qualifier: { - type: 'TSQualifiedName', - start: 35, - end: 62, - loc: { - start: { - line: 2, - column: 22, - }, - end: { - line: 2, - column: 49, - }, - }, - left: { - type: 'TSQualifiedName', - start: 35, - end: 48, - loc: { - start: { - line: 2, - column: 22, - }, - end: { - line: 2, - column: 35, - }, - }, - left: { - type: 'TSQualifiedName', - start: 35, - end: 42, - loc: { - start: { - line: 2, - column: 22, - }, - end: { - line: 2, - column: 29, - }, - }, - left: { - type: 'Identifier', - start: 35, - end: 38, - loc: { - start: { - line: 2, - column: 22, - }, - end: { - line: 2, - column: 25, - }, - identifierName: 'bar', - }, - name: 'bar', - }, - right: { - type: 'Identifier', - start: 39, - end: 42, - loc: { - start: { - line: 2, - column: 26, - }, - end: { - line: 2, - column: 29, - }, - identifierName: 'baz', - }, - name: 'baz', - }, - }, - right: { - type: 'Identifier', - start: 43, - end: 48, - loc: { - start: { - line: 2, - column: 30, - }, - end: { - line: 2, - column: 35, - }, - identifierName: 'types', - }, - name: 'types', - }, - }, - right: { - type: 'Identifier', - start: 49, - end: 62, - loc: { - start: { - line: 2, - column: 36, - }, - end: { - line: 2, - column: 49, - }, - identifierName: 'ComponentType', - }, - name: 'ComponentType', - }, - }, - }, - indexType: { - type: 'TSLiteralType', - start: 64, - end: 77, - loc: { - start: { - line: 2, - column: 51, - }, - end: { - line: 2, - column: 64, - }, - }, - literal: { - type: 'StringLiteral', - start: 64, - end: 77, - loc: { - start: { - line: 2, - column: 51, - }, - end: { - line: 2, - column: 64, - }, - }, - extra: { - rawValue: 'displayName', - raw: "'displayName'", - }, - value: 'displayName', - }, - }, - }, - }, - }, - { - type: 'RestElement', - start: 82, - end: 133, - loc: { - start: { - line: 3, - column: 1, - }, - end: { - line: 3, - column: 52, - }, - }, - argument: { - type: 'Identifier', - start: 85, - end: 89, - loc: { - start: { - line: 3, - column: 4, - }, - end: { - line: 3, - column: 8, - }, - identifierName: 'rest', - }, - name: 'rest', - }, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 89, - end: 133, - loc: { - start: { - line: 3, - column: 8, - }, - end: { - line: 3, - column: 52, - }, - }, - typeAnnotation: { - type: 'TSTupleType', - start: 91, - end: 133, - loc: { - start: { - line: 3, - column: 10, - }, - end: { - line: 3, - column: 52, - }, - }, - elementTypes: [ - { - type: 'TSUnionType', - start: 93, - end: 108, - loc: { - start: { - line: 3, - column: 12, - }, - end: { - line: 3, - column: 27, - }, - }, - types: [ - { - type: 'TSStringKeyword', - start: 93, - end: 99, - loc: { - start: { - line: 3, - column: 12, - }, - end: { - line: 3, - column: 18, - }, - }, - }, - { - type: 'TSNumberKeyword', - start: 102, - end: 108, - loc: { - start: { - line: 3, - column: 21, - }, - end: { - line: 3, - column: 27, - }, - }, - }, - ], - }, - { - type: 'TSRestType', - start: 110, - end: 131, - loc: { - start: { - line: 3, - column: 29, - }, - end: { - line: 3, - column: 50, - }, - }, - typeAnnotation: { - type: 'TSParenthesizedType', - start: 113, - end: 131, - loc: { - start: { - line: 3, - column: 32, - }, - end: { - line: 3, - column: 50, - }, - }, - typeAnnotation: { - type: 'TSTypeOperator', - start: 115, - end: 129, - loc: { - start: { - line: 3, - column: 34, - }, - end: { - line: 3, - column: 48, - }, - }, - operator: 'keyof', - typeAnnotation: { - type: 'TSTypeReference', - start: 121, - end: 129, - loc: { - start: { - line: 3, - column: 40, - }, - end: { - line: 3, - column: 48, - }, - }, - typeName: { - type: 'Identifier', - start: 121, - end: 129, - loc: { - start: { - line: 3, - column: 40, - }, - end: { - line: 3, - column: 48, - }, - identifierName: 'constant', - }, - name: 'constant', - }, - }, - }, - }, - }, - ], - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 135, - end: 150, - loc: { - start: { - line: 4, - column: 1, - }, - end: { - line: 4, - column: 16, - }, - }, - typeAnnotation: { - type: 'TSTypePredicate', - start: 135, - end: 150, - loc: { - start: { - line: 4, - column: 1, - }, - end: { - line: 4, - column: 16, - }, - }, - parameterName: { - type: 'Identifier', - start: 137, - end: 140, - loc: { - start: { - line: 4, - column: 3, - }, - end: { - line: 4, - column: 6, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 144, - end: 150, - loc: { - start: { - line: 4, - column: 10, - }, - end: { - line: 4, - column: 16, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 144, - end: 150, - loc: { - start: { - line: 4, - column: 10, - }, - end: { - line: 4, - column: 16, - }, - }, - }, - }, - asserts: false, - }, - }, - body: { - type: 'BlockStatement', - start: 151, - end: 153, - loc: { - start: { - line: 4, - column: 17, - }, - end: { - line: 4, - column: 19, - }, - }, - body: [], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/literal-values/example.ts b/packages/docgen/test/fixtures/type-annotations/literal-values/example.ts deleted file mode 100644 index b50db1a869291..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/literal-values/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -function fn( foo: 'a-string-literal' ): 1000n { - return BigInt( '1000' ) as 1000n; -} diff --git a/packages/docgen/test/fixtures/type-annotations/literal-values/get-node.js b/packages/docgen/test/fixtures/type-annotations/literal-values/get-node.js deleted file mode 100644 index 9044d649443f2..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/literal-values/get-node.js +++ /dev/null @@ -1,162 +0,0 @@ -module.exports = ( { literalType, literalValue } ) => ( { - type: 'FunctionDeclaration', - start: 22, - end: 65, - loc: { - start: { - line: 3, - column: 0, - }, - end: { - line: 3, - column: 43, - }, - }, - id: { - type: 'Identifier', - start: 31, - end: 33, - loc: { - start: { - line: 3, - column: 9, - }, - end: { - line: 3, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 34, - end: 55, - loc: { - start: { - line: 3, - column: 12, - }, - end: { - line: 3, - column: 33, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 37, - end: 55, - loc: { - start: { - line: 3, - column: 15, - }, - end: { - line: 3, - column: 33, - }, - }, - typeAnnotation: { - type: 'TSLiteralType', - start: 39, - end: 55, - loc: { - start: { - line: 3, - column: 17, - }, - end: { - line: 3, - column: 33, - }, - }, - literal: { - type: literalType, - start: 39, - end: 55, - loc: { - start: { - line: 3, - column: 17, - }, - end: { - line: 3, - column: 33, - }, - }, - value: literalValue, - }, - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 56, - end: 62, - loc: { - start: { - line: 3, - column: 34, - }, - end: { - line: 3, - column: 40, - }, - }, - typeAnnotation: { - type: 'TSLiteralType', - start: 58, - end: 62, - loc: { - start: { - line: 3, - column: 36, - }, - end: { - line: 3, - column: 40, - }, - }, - literal: { - type: literalType, - start: 58, - end: 62, - loc: { - start: { - line: 3, - column: 36, - }, - end: { - line: 3, - column: 40, - }, - }, - value: literalValue, - }, - }, - }, - body: { - type: 'BlockStatement', - start: 63, - end: 65, - loc: { - start: { - line: 3, - column: 41, - }, - end: { - line: 3, - column: 43, - }, - }, - body: [], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/missing-types/example.ts b/packages/docgen/test/fixtures/type-annotations/missing-types/example.ts deleted file mode 100644 index 91949541bb8fd..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/missing-types/example.ts +++ /dev/null @@ -1 +0,0 @@ -function fn( foo ) {} diff --git a/packages/docgen/test/fixtures/type-annotations/missing-types/get-node.js b/packages/docgen/test/fixtures/type-annotations/missing-types/get-node.js deleted file mode 100644 index 0331fb2d1b24d..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/missing-types/get-node.js +++ /dev/null @@ -1,104 +0,0 @@ -module.exports = () => ( { - type: 'VariableDeclaration', - start: 0, - end: 22, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 1, - column: 22, - }, - }, - declarations: [ - { - type: 'VariableDeclarator', - start: 6, - end: 22, - loc: { - start: { - line: 1, - column: 6, - }, - end: { - line: 1, - column: 22, - }, - }, - id: { - type: 'Identifier', - start: 6, - end: 8, - loc: { - start: { - line: 1, - column: 6, - }, - end: { - line: 1, - column: 8, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - init: { - type: 'ArrowFunctionExpression', - start: 11, - end: 22, - loc: { - start: { - line: 1, - column: 11, - }, - end: { - line: 1, - column: 22, - }, - }, - id: null, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 12, - end: 15, - loc: { - start: { - line: 1, - column: 12, - }, - end: { - line: 1, - column: 15, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - ], - body: { - type: 'BlockStatement', - start: 20, - end: 22, - loc: { - start: { - line: 1, - column: 20, - }, - end: { - line: 1, - column: 22, - }, - }, - body: [], - directives: [], - }, - }, - }, - ], - kind: 'const', -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/named-export/example.ts b/packages/docgen/test/fixtures/type-annotations/named-export/example.ts deleted file mode 100644 index c76c9afdb53b0..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/named-export/example.ts +++ /dev/null @@ -1 +0,0 @@ -export function fn( foo: string ): string {} diff --git a/packages/docgen/test/fixtures/type-annotations/named-export/get-node.js b/packages/docgen/test/fixtures/type-annotations/named-export/get-node.js deleted file mode 100644 index 568dc563fd063..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/named-export/get-node.js +++ /dev/null @@ -1,148 +0,0 @@ -module.exports = () => ( { - type: 'ExportNamedDeclaration', - start: 0, - end: 42, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 1, - column: 42, - }, - }, - exportKind: 'value', - specifiers: [], - source: null, - declaration: { - type: 'FunctionDeclaration', - start: 7, - end: 42, - loc: { - start: { - line: 1, - column: 7, - }, - end: { - line: 1, - column: 42, - }, - }, - id: { - type: 'Identifier', - start: 16, - end: 18, - loc: { - start: { - line: 1, - column: 16, - }, - end: { - line: 1, - column: 18, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 19, - end: 30, - loc: { - start: { - line: 1, - column: 19, - }, - end: { - line: 1, - column: 30, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 22, - end: 30, - loc: { - start: { - line: 1, - column: 22, - }, - end: { - line: 1, - column: 30, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 24, - end: 30, - loc: { - start: { - line: 1, - column: 24, - }, - end: { - line: 1, - column: 30, - }, - }, - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 31, - end: 39, - loc: { - start: { - line: 1, - column: 31, - }, - end: { - line: 1, - column: 39, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 33, - end: 39, - loc: { - start: { - line: 1, - column: 33, - }, - end: { - line: 1, - column: 39, - }, - }, - }, - }, - body: { - type: 'BlockStatement', - start: 40, - end: 42, - loc: { - start: { - line: 1, - column: 40, - }, - end: { - line: 1, - column: 42, - }, - }, - body: [], - directives: [], - }, - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/example.ts b/packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/example.ts deleted file mode 100644 index dc79b7e92cef0..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/example.ts +++ /dev/null @@ -1,3 +0,0 @@ -function fn( { foo, ...rest }: { foo: string } ): string { - return foo; -} diff --git a/packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/get-node.js b/packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/get-node.js deleted file mode 100644 index 7ed2116e145b4..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/object-destructuring-object-literal-type/get-node.js +++ /dev/null @@ -1,315 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 0, - end: 73, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 3, - column: 1, - }, - }, - id: { - type: 'Identifier', - start: 9, - end: 11, - loc: { - start: { - line: 1, - column: 9, - }, - end: { - line: 1, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'ObjectPattern', - start: 13, - end: 46, - loc: { - start: { - line: 1, - column: 13, - }, - end: { - line: 1, - column: 46, - }, - }, - properties: [ - { - type: 'ObjectProperty', - start: 15, - end: 18, - loc: { - start: { - line: 1, - column: 15, - }, - end: { - line: 1, - column: 18, - }, - }, - extra: { - shorthand: true, - }, - method: false, - key: { - type: 'Identifier', - start: 15, - end: 18, - loc: { - start: { - line: 1, - column: 15, - }, - end: { - line: 1, - column: 18, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - computed: false, - shorthand: true, - value: { - type: 'Identifier', - start: 15, - end: 18, - loc: { - start: { - line: 1, - column: 15, - }, - end: { - line: 1, - column: 18, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - }, - { - type: 'RestElement', - start: 20, - end: 27, - loc: { - start: { - line: 1, - column: 20, - }, - end: { - line: 1, - column: 27, - }, - }, - argument: { - type: 'Identifier', - start: 23, - end: 27, - loc: { - start: { - line: 1, - column: 23, - }, - end: { - line: 1, - column: 27, - }, - identifierName: 'rest', - }, - name: 'rest', - }, - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 29, - end: 46, - loc: { - start: { - line: 1, - column: 29, - }, - end: { - line: 1, - column: 46, - }, - }, - typeAnnotation: { - type: 'TSTypeLiteral', - start: 31, - end: 46, - loc: { - start: { - line: 1, - column: 31, - }, - end: { - line: 1, - column: 46, - }, - }, - members: [ - { - type: 'TSPropertySignature', - start: 33, - end: 44, - loc: { - start: { - line: 1, - column: 33, - }, - end: { - line: 1, - column: 44, - }, - }, - key: { - type: 'Identifier', - start: 33, - end: 36, - loc: { - start: { - line: 1, - column: 33, - }, - end: { - line: 1, - column: 36, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - computed: false, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 36, - end: 44, - loc: { - start: { - line: 1, - column: 36, - }, - end: { - line: 1, - column: 44, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 38, - end: 44, - loc: { - start: { - line: 1, - column: 38, - }, - end: { - line: 1, - column: 44, - }, - }, - }, - }, - }, - ], - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 48, - end: 56, - loc: { - start: { - line: 1, - column: 48, - }, - end: { - line: 1, - column: 56, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 50, - end: 56, - loc: { - start: { - line: 1, - column: 50, - }, - end: { - line: 1, - column: 56, - }, - }, - }, - }, - body: { - type: 'BlockStatement', - start: 57, - end: 73, - loc: { - start: { - line: 1, - column: 57, - }, - end: { - line: 3, - column: 1, - }, - }, - body: [ - { - type: 'ReturnStatement', - start: 60, - end: 71, - loc: { - start: { - line: 2, - column: 1, - }, - end: { - line: 2, - column: 12, - }, - }, - argument: { - type: 'Identifier', - start: 67, - end: 70, - loc: { - start: { - line: 2, - column: 8, - }, - end: { - line: 2, - column: 11, - }, - identifierName: 'foo', - }, - name: 'foo', - }, - }, - ], - directives: [], - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/simple-types/example.ts b/packages/docgen/test/fixtures/type-annotations/simple-types/example.ts deleted file mode 100644 index 135fe07f529ec..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/simple-types/example.ts +++ /dev/null @@ -1 +0,0 @@ -function fn( foo: any ): any {} diff --git a/packages/docgen/test/fixtures/type-annotations/simple-types/get-node.js b/packages/docgen/test/fixtures/type-annotations/simple-types/get-node.js deleted file mode 100644 index 47c2c7c469524..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/simple-types/get-node.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = ( { - paramType = 'TSAnyKeyword', - returnType = 'TSAnyKeyword', -} = {} ) => ( { - type: 'FunctionDeclaration', - id: { - type: 'Identifier', - name: 'fn', - range: [ 9, 11 ], - }, - generator: false, - expression: false, - async: false, - params: [ - { - type: 'Identifier', - name: 'foo', - range: [ 12, 20 ], - typeAnnotation: { - type: 'TSTypeAnnotation', - range: [ 15, 20 ], - typeAnnotation: { - type: paramType, - range: [ 17, 20 ], - }, - }, - }, - ], - body: { - type: 'BlockStatement', - body: [], - range: [ 27, 29 ], - }, - range: [ 0, 29 ], - returnType: { - type: 'TSTypeAnnotation', - range: [ 21, 26 ], - typeAnnotation: { - type: returnType, - range: [ 23, 26 ], - }, - }, -} ); diff --git a/packages/docgen/test/fixtures/type-annotations/type-literals/example.ts b/packages/docgen/test/fixtures/type-annotations/type-literals/example.ts deleted file mode 100644 index 02174d2e5ef5c..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/type-literals/example.ts +++ /dev/null @@ -1,11 +0,0 @@ -function fn( foo: { - ( bar: string ): void; - bar: string; - optionalBar?: 'left' | 'right'; - [ key: number ]: string; -} ): { - ( bar: string ): void; - bar: string; - optionalBar?: 'left' | 'right'; - [ key: number ]: string; -} {} diff --git a/packages/docgen/test/fixtures/type-annotations/type-literals/get-node.js b/packages/docgen/test/fixtures/type-annotations/type-literals/get-node.js deleted file mode 100644 index 7f0a5e7c21655..0000000000000 --- a/packages/docgen/test/fixtures/type-annotations/type-literals/get-node.js +++ /dev/null @@ -1,908 +0,0 @@ -module.exports = () => ( { - type: 'FunctionDeclaration', - start: 0, - end: 229, - loc: { - start: { - line: 1, - column: 0, - }, - end: { - line: 13, - column: 4, - }, - }, - id: { - type: 'Identifier', - start: 9, - end: 11, - loc: { - start: { - line: 1, - column: 9, - }, - end: { - line: 1, - column: 11, - }, - identifierName: 'fn', - }, - name: 'fn', - }, - generator: false, - async: false, - params: [ - { - type: 'Identifier', - start: 14, - end: 126, - loc: { - start: { - line: 2, - column: 1, - }, - end: { - line: 7, - column: 2, - }, - identifierName: 'foo', - }, - name: 'foo', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 17, - end: 126, - loc: { - start: { - line: 2, - column: 4, - }, - end: { - line: 7, - column: 2, - }, - }, - typeAnnotation: { - type: 'TSTypeLiteral', - start: 19, - end: 126, - loc: { - start: { - line: 2, - column: 6, - }, - end: { - line: 7, - column: 2, - }, - }, - members: [ - { - type: 'TSCallSignatureDeclaration', - start: 27, - end: 47, - loc: { - start: { - line: 3, - column: 5, - }, - end: { - line: 3, - column: 25, - }, - }, - parameters: [ - { - type: 'Identifier', - start: 28, - end: 39, - loc: { - start: { - line: 3, - column: 6, - }, - end: { - line: 3, - column: 17, - }, - identifierName: 'bar', - }, - name: 'bar', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 31, - end: 39, - loc: { - start: { - line: 3, - column: 9, - }, - end: { - line: 3, - column: 17, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 33, - end: 39, - loc: { - start: { - line: 3, - column: 11, - }, - end: { - line: 3, - column: 17, - }, - }, - }, - }, - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 40, - end: 46, - loc: { - start: { - line: 3, - column: 18, - }, - end: { - line: 3, - column: 24, - }, - }, - typeAnnotation: { - type: 'TSVoidKeyword', - start: 42, - end: 46, - loc: { - start: { - line: 3, - column: 20, - }, - end: { - line: 3, - column: 24, - }, - }, - }, - }, - }, - { - type: 'TSPropertySignature', - start: 53, - end: 65, - loc: { - start: { - line: 4, - column: 5, - }, - end: { - line: 4, - column: 17, - }, - }, - key: { - type: 'Identifier', - start: 53, - end: 56, - loc: { - start: { - line: 4, - column: 5, - }, - end: { - line: 4, - column: 8, - }, - identifierName: 'bar', - }, - name: 'bar', - }, - computed: false, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 56, - end: 64, - loc: { - start: { - line: 4, - column: 8, - }, - end: { - line: 4, - column: 16, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 58, - end: 64, - loc: { - start: { - line: 4, - column: 10, - }, - end: { - line: 4, - column: 16, - }, - }, - }, - }, - }, - { - type: 'TSPropertySignature', - start: 68, - end: 99, - loc: { - start: { - line: 5, - column: 2, - }, - end: { - line: 5, - column: 33, - }, - }, - key: { - type: 'Identifier', - start: 68, - end: 79, - loc: { - start: { - line: 5, - column: 2, - }, - end: { - line: 5, - column: 13, - }, - identifierName: 'optionalBar', - }, - name: 'optionalBar', - }, - computed: false, - optional: true, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 80, - end: 98, - loc: { - start: { - line: 5, - column: 14, - }, - end: { - line: 5, - column: 32, - }, - }, - typeAnnotation: { - type: 'TSUnionType', - start: 82, - end: 98, - loc: { - start: { - line: 5, - column: 16, - }, - end: { - line: 5, - column: 32, - }, - }, - types: [ - { - type: 'TSLiteralType', - start: 82, - end: 88, - loc: { - start: { - line: 5, - column: 16, - }, - end: { - line: 5, - column: 22, - }, - }, - literal: { - type: 'StringLiteral', - start: 82, - end: 88, - loc: { - start: { - line: 5, - column: 16, - }, - end: { - line: 5, - column: 22, - }, - }, - extra: { - rawValue: 'left', - raw: "'left'", - }, - value: 'left', - }, - }, - { - type: 'TSLiteralType', - start: 91, - end: 98, - loc: { - start: { - line: 5, - column: 25, - }, - end: { - line: 5, - column: 32, - }, - }, - literal: { - type: 'StringLiteral', - start: 91, - end: 98, - loc: { - start: { - line: 5, - column: 25, - }, - end: { - line: 5, - column: 32, - }, - }, - extra: { - rawValue: 'right', - raw: "'right'", - }, - value: 'right', - }, - }, - ], - }, - }, - }, - { - type: 'TSIndexSignature', - start: 102, - end: 123, - loc: { - start: { - line: 6, - column: 2, - }, - end: { - line: 6, - column: 23, - }, - }, - parameters: [ - { - type: 'Identifier', - start: 103, - end: 114, - loc: { - start: { - line: 6, - column: 3, - }, - end: { - line: 6, - column: 14, - }, - identifierName: 'key', - }, - name: 'key', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 106, - end: 114, - loc: { - start: { - line: 6, - column: 6, - }, - end: { - line: 6, - column: 14, - }, - }, - typeAnnotation: { - type: 'TSNumberKeyword', - start: 108, - end: 114, - loc: { - start: { - line: 6, - column: 8, - }, - end: { - line: 6, - column: 14, - }, - }, - }, - }, - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 115, - end: 123, - loc: { - start: { - line: 6, - column: 15, - }, - end: { - line: 6, - column: 23, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 117, - end: 123, - loc: { - start: { - line: 6, - column: 17, - }, - end: { - line: 6, - column: 23, - }, - }, - }, - }, - }, - ], - }, - }, - }, - ], - returnType: { - type: 'TSTypeAnnotation', - start: 128, - end: 226, - loc: { - start: { - line: 8, - column: 1, - }, - end: { - line: 13, - column: 1, - }, - }, - typeAnnotation: { - type: 'TSTypeLiteral', - start: 130, - end: 226, - loc: { - start: { - line: 8, - column: 3, - }, - end: { - line: 13, - column: 1, - }, - }, - members: [ - { - type: 'TSCallSignatureDeclaration', - start: 134, - end: 154, - loc: { - start: { - line: 9, - column: 1, - }, - end: { - line: 9, - column: 21, - }, - }, - parameters: [ - { - type: 'Identifier', - start: 135, - end: 146, - loc: { - start: { - line: 9, - column: 2, - }, - end: { - line: 9, - column: 13, - }, - identifierName: 'bar', - }, - name: 'bar', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 138, - end: 146, - loc: { - start: { - line: 9, - column: 5, - }, - end: { - line: 9, - column: 13, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 140, - end: 146, - loc: { - start: { - line: 9, - column: 7, - }, - end: { - line: 9, - column: 13, - }, - }, - }, - }, - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 147, - end: 153, - loc: { - start: { - line: 9, - column: 14, - }, - end: { - line: 9, - column: 20, - }, - }, - typeAnnotation: { - type: 'TSVoidKeyword', - start: 149, - end: 153, - loc: { - start: { - line: 9, - column: 16, - }, - end: { - line: 9, - column: 20, - }, - }, - }, - }, - }, - { - type: 'TSPropertySignature', - start: 156, - end: 168, - loc: { - start: { - line: 10, - column: 1, - }, - end: { - line: 10, - column: 13, - }, - }, - key: { - type: 'Identifier', - start: 156, - end: 159, - loc: { - start: { - line: 10, - column: 1, - }, - end: { - line: 10, - column: 4, - }, - identifierName: 'bar', - }, - name: 'bar', - }, - computed: false, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 159, - end: 167, - loc: { - start: { - line: 10, - column: 4, - }, - end: { - line: 10, - column: 12, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 161, - end: 167, - loc: { - start: { - line: 10, - column: 6, - }, - end: { - line: 10, - column: 12, - }, - }, - }, - }, - }, - { - type: 'TSPropertySignature', - start: 170, - end: 201, - loc: { - start: { - line: 11, - column: 1, - }, - end: { - line: 11, - column: 32, - }, - }, - key: { - type: 'Identifier', - start: 170, - end: 181, - loc: { - start: { - line: 11, - column: 1, - }, - end: { - line: 11, - column: 12, - }, - identifierName: 'optionalBar', - }, - name: 'optionalBar', - }, - computed: false, - optional: true, - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 182, - end: 200, - loc: { - start: { - line: 11, - column: 13, - }, - end: { - line: 11, - column: 31, - }, - }, - typeAnnotation: { - type: 'TSUnionType', - start: 184, - end: 200, - loc: { - start: { - line: 11, - column: 15, - }, - end: { - line: 11, - column: 31, - }, - }, - types: [ - { - type: 'TSLiteralType', - start: 184, - end: 190, - loc: { - start: { - line: 11, - column: 15, - }, - end: { - line: 11, - column: 21, - }, - }, - literal: { - type: 'StringLiteral', - start: 184, - end: 190, - loc: { - start: { - line: 11, - column: 15, - }, - end: { - line: 11, - column: 21, - }, - }, - extra: { - rawValue: 'left', - raw: "'left'", - }, - value: 'left', - }, - }, - { - type: 'TSLiteralType', - start: 193, - end: 200, - loc: { - start: { - line: 11, - column: 24, - }, - end: { - line: 11, - column: 31, - }, - }, - literal: { - type: 'StringLiteral', - start: 193, - end: 200, - loc: { - start: { - line: 11, - column: 24, - }, - end: { - line: 11, - column: 31, - }, - }, - extra: { - rawValue: 'right', - raw: "'right'", - }, - value: 'right', - }, - }, - ], - }, - }, - }, - { - type: 'TSIndexSignature', - start: 203, - end: 224, - loc: { - start: { - line: 12, - column: 1, - }, - end: { - line: 12, - column: 22, - }, - }, - parameters: [ - { - type: 'Identifier', - start: 204, - end: 215, - loc: { - start: { - line: 12, - column: 2, - }, - end: { - line: 12, - column: 13, - }, - identifierName: 'key', - }, - name: 'key', - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 207, - end: 215, - loc: { - start: { - line: 12, - column: 5, - }, - end: { - line: 12, - column: 13, - }, - }, - typeAnnotation: { - type: 'TSNumberKeyword', - start: 209, - end: 215, - loc: { - start: { - line: 12, - column: 7, - }, - end: { - line: 12, - column: 13, - }, - }, - }, - }, - }, - ], - typeAnnotation: { - type: 'TSTypeAnnotation', - start: 216, - end: 224, - loc: { - start: { - line: 12, - column: 14, - }, - end: { - line: 12, - column: 22, - }, - }, - typeAnnotation: { - type: 'TSStringKeyword', - start: 218, - end: 224, - loc: { - start: { - line: 12, - column: 16, - }, - end: { - line: 12, - column: 22, - }, - }, - }, - }, - }, - ], - }, - }, - body: { - type: 'BlockStatement', - start: 227, - end: 229, - loc: { - start: { - line: 13, - column: 2, - }, - end: { - line: 13, - column: 4, - }, - }, - body: [], - directives: [], - }, -} ); diff --git a/packages/docgen/test/get-export-entries.js b/packages/docgen/test/get-export-entries.js index 7ac4db3dbe889..4d4346007b3aa 100644 --- a/packages/docgen/test/get-export-entries.js +++ b/packages/docgen/test/get-export-entries.js @@ -1,319 +1,505 @@ /** * Internal dependencies */ +const engine = require( '../lib/engine' ); const getExportEntries = require( '../lib/get-export-entries' ); +/** + * Parses sample code into testable structure. + * + * @param {string} code Sourcecode to analyze in test. + * @param {string} [importedCode] Sourcecode for module imported in `code`. + */ +const parse = ( code, importedCode ) => + engine( + 'test-code.ts', + code.trim(), + importedCode + ? () => engine( 'module-code.ts', importedCode.trim() ).ir + : undefined + ).tokens; + +/** + * Useful for tests asserting properties on the first (or only) export. + * + * @param {string} code Sourcecode to analyze in test. + * @param {string} [importedCode] Sourcecode for module imported in `code`. + */ +const firstExport = ( code, importedCode ) => + getExportEntries( parse( code, importedCode )[ 0 ] ); + describe( 'Export entries', () => { - it( 'default class (anonymous)', () => { - const token = require( './fixtures/default-class-anonymous/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: '*default*', - exportName: 'default', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + it( 'default class (anonymous)', () => + expect( + firstExport( ` + /** + * Class declaration example. + */ + export default class {} + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: '*default*', + exportName: 'default', + module: null, + } ), + ] ) ); - it( 'default class (named)', () => { - const token = require( './fixtures/default-class-named/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'ClassDeclaration', - exportName: 'default', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + it( 'default class (named)', () => + expect( + firstExport( ` + /** + * Class declaration example. + */ + export default class ClassDeclaration {} + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'ClassDeclaration', + exportName: 'default', + module: null, + } ), + ] ) ); - it( 'default function (anonymous)', () => { - const token = require( './fixtures/default-function-anonymous/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: '*default*', - exportName: 'default', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + it( 'default function (anonymous)', () => + expect( + firstExport( ` + /** + * Function declaration example. + */ + export default () => {} + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: '*default*', + exportName: 'default', + module: null, + } ), + ] ) ); - it( 'default function (named)', () => { - const token = require( './fixtures/default-function-named/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'myDeclaration', - exportName: 'default', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + it( 'default function (named)', () => + expect( + firstExport( ` + /** + * Function declaration example. + */ + export default function myDeclaration() {} + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'myDeclaration', + exportName: 'default', + module: null, + } ), + ] ) ); - it( 'default identifier', () => { - const token = require( './fixtures/default-identifier/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'ClassDeclaration', - exportName: 'default', - module: null, - lineStart: 6, - lineEnd: 6, - } ); - } ); + it( 'default identifier', () => + expect( + firstExport( ` + /** + * Class declaration example. + */ + class ClassDeclaration {} + + export default ClassDeclaration; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'ClassDeclaration', + exportName: 'default', + module: null, + } ), + ] ) ); it( 'default import (named)', () => { - const token = require( './fixtures/default-import-named/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'fnDeclaration', - exportName: 'default', - module: null, - lineStart: 3, - lineEnd: 3, - } ); - } ); + const testCode = firstExport( + ` + /** + * Internal dependencies + */ + import { functionDeclaration as fnDeclaration } from './module-code'; - it( 'default import (default)', () => { - const token = require( './fixtures/default-import-default/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'fnDeclaration', - exportName: 'default', - module: null, - lineStart: 3, - lineEnd: 3, - } ); + export default fnDeclaration; + `, + ` + /** + * Function declaration. + */ + function functionDeclaration() {} + + export default functionDeclaration; + ` + ); + expect( testCode ).toEqual( [ + expect.objectContaining( { + localName: 'fnDeclaration', + exportName: 'default', + module: null, + } ), + ] ); } ); + it( 'default import (default)', () => + expect( + firstExport( + ` + /** + * Internal dependencies + */ + import fnDeclaration from './module-code'; + + export default fnDeclaration; + `, + ` + /** + * Function declaration. + */ + function functionDeclaration() {} + + export default functionDeclaration; + ` + ) + ).toEqual( [ + expect.objectContaining( { + localName: 'fnDeclaration', + exportName: 'default', + module: null, + } ), + ] ) ); + it( 'default named export', () => { - const tokens = require( './fixtures/default-named-export/exports.json' ); - const namedExport = getExportEntries( tokens[ 0 ] ); - expect( namedExport ).toHaveLength( 1 ); - expect( namedExport[ 0 ] ).toEqual( { - localName: 'functionDeclaration', - exportName: 'functionDeclaration', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - const defaultExport = getExportEntries( tokens[ 1 ] ); - expect( defaultExport ).toHaveLength( 1 ); - expect( defaultExport[ 0 ] ).toEqual( { - localName: 'functionDeclaration', - exportName: 'default', - module: null, - lineStart: 6, - lineEnd: 6, - } ); - } ); + const [ namedExport, defaultExport ] = parse( + ` + /** + * Function declaration example. + */ + export function functionDeclaration() {} - it( 'default variable', () => { - const token = require( './fixtures/default-variable/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: '*default*', - exportName: 'default', - module: null, - lineStart: 4, - lineEnd: 4, - } ); + export default functionDeclaration; + ` + ).map( ( token ) => getExportEntries( token ) ); + expect( namedExport ).toEqual( [ + expect.objectContaining( { + localName: 'functionDeclaration', + exportName: 'functionDeclaration', + module: null, + } ), + ] ); + expect( defaultExport ).toEqual( [ + expect.objectContaining( { + localName: 'functionDeclaration', + exportName: 'default', + module: null, + } ), + ] ); } ); - it( 'named class', () => { - const token = require( './fixtures/named-class/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'MyDeclaration', - exportName: 'MyDeclaration', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + it( 'default variable', () => + expect( + firstExport( ` + /** + * Variable declaration example. + */ + export default true; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: '*default*', + exportName: 'default', + module: null, + } ), + ] ) ); - it( 'named default', () => { - const token = require( './fixtures/named-default/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'default', - exportName: 'default', - module: './named-default-module', - lineStart: 1, - lineEnd: 1, - } ); - } ); + it( 'named class', () => + expect( + firstExport( ` + /** + * My declaration example. + */ + export class MyDeclaration {} + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'MyDeclaration', + exportName: 'MyDeclaration', + module: null, + lineStart: 4, + lineEnd: 4, + } ), + ] ) ); - it( 'named default (exported)', () => { - const token = require( './fixtures/named-default-exported/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'default', - exportName: 'moduleName', - module: './named-default-module', - lineStart: 1, - lineEnd: 1, - } ); - } ); + it( 'named default', () => + expect( + firstExport( + ` + export { default } from './module-code'; + `, + ` + /** + * Module declaration. + */ + export default function () {} + ` + ) + ).toEqual( [ + expect.objectContaining( { + localName: 'default', + exportName: 'default', + module: './module-code', + } ), + ] ) ); - it( 'named function', () => { - const token = require( './fixtures/named-function/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'myDeclaration', - exportName: 'myDeclaration', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + it( 'named default (exported)', () => + expect( + firstExport( + ` + export { default as moduleName } from './module-code'; + `, + ` + /** + * Module declaration. + */ + export default function () {} + ` + ) + ).toEqual( [ + expect.objectContaining( { + localName: 'default', + exportName: 'moduleName', + module: './module-code', + } ), + ] ) ); + + it( 'named function', () => + expect( + firstExport( ` + /** + * My declaration example. + */ + export function myDeclaration() {} + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'myDeclaration', + exportName: 'myDeclaration', + module: null, + } ), + ] ) ); it( 'named identifier', () => { - const token = require( './fixtures/named-identifier/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'myDeclaration', - exportName: 'myDeclaration', - module: null, - lineStart: 6, - lineEnd: 6, - } ); - const tokenObject = require( './fixtures/named-identifier-destructuring/exports.json' ); - const nameObject = getExportEntries( tokenObject ); - expect( nameObject ).toHaveLength( 1 ); - expect( nameObject[ 0 ] ).toEqual( { - localName: 'someDeclaration', - exportName: 'myDeclaration', - module: null, - lineStart: 6, - lineEnd: 6, - } ); + expect( + firstExport( ` + /** + * My declaration example. + */ + function myDeclaration() {} + + export { myDeclaration }; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'myDeclaration', + exportName: 'myDeclaration', + module: null, + } ), + ] ); + + expect( + firstExport( ` + /** + * My declaration example. + */ + const { someDeclaration } = { someDeclaration: () => {} }; + + export { someDeclaration as myDeclaration }; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'someDeclaration', + exportName: 'myDeclaration', + module: null, + } ), + ] ); } ); it( 'named identifiers', () => { - const token = require( './fixtures/named-identifiers/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 3 ); - expect( name[ 0 ] ).toEqual( { - localName: 'functionDeclaration', - exportName: 'functionDeclaration', - module: null, - lineStart: 16, - lineEnd: 16, - } ); - expect( name[ 1 ] ).toEqual( { - localName: 'variableDeclaration', - exportName: 'variableDeclaration', - module: null, - lineStart: 16, - lineEnd: 16, - } ); - expect( name[ 2 ] ).toEqual( { - localName: 'ClassDeclaration', - exportName: 'ClassDeclaration', - module: null, - lineStart: 16, - lineEnd: 16, - } ); - const tokenIdentifiersAndInline = require( './fixtures/named-identifiers-and-inline/exports.json' ); - const nameInline0 = getExportEntries( tokenIdentifiersAndInline[ 0 ] ); - expect( nameInline0 ).toHaveLength( 2 ); - expect( nameInline0[ 0 ] ).toEqual( { - localName: 'functionDeclaration', - exportName: 'functionDeclaration', - module: null, - lineStart: 11, - lineEnd: 11, - } ); - expect( nameInline0[ 1 ] ).toEqual( { - localName: 'ClassDeclaration', - exportName: 'ClassDeclaration', - module: null, - lineStart: 11, - lineEnd: 11, - } ); - const nameInline1 = getExportEntries( tokenIdentifiersAndInline[ 1 ] ); - expect( nameInline1 ).toHaveLength( 1 ); - expect( nameInline1[ 0 ] ).toEqual( { - localName: 'variableDeclaration', - exportName: 'variableDeclaration', - module: null, - lineStart: 16, - lineEnd: 16, - } ); - } ); + expect( + firstExport( ` + /** + * Function declaration example. + */ + function functionDeclaration() {} - it( 'named import namespace', () => { - const token = require( './fixtures/named-import-namespace/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'variables', - exportName: 'variables', - module: null, - lineStart: 3, - lineEnd: 3, - } ); - } ); + /** + * Class declaration example. + */ + class ClassDeclaration {} - it( 'named variable', () => { - const token = require( './fixtures/named-variable/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: 'myDeclaration', - exportName: 'myDeclaration', - module: null, - lineStart: 4, - lineEnd: 4, - } ); - } ); + /** + * Variable declaration example. + */ + const variableDeclaration = true; + + export { functionDeclaration, variableDeclaration, ClassDeclaration }; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'functionDeclaration', + exportName: 'functionDeclaration', + module: null, + } ), + expect.objectContaining( { + localName: 'variableDeclaration', + exportName: 'variableDeclaration', + module: null, + } ), + expect.objectContaining( { + localName: 'ClassDeclaration', + exportName: 'ClassDeclaration', + module: null, + } ), + ] ); - it( 'named variables', () => { - const token = require( './fixtures/named-variables/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 2 ); - expect( name[ 0 ] ).toEqual( { - localName: 'firstDeclaration', - exportName: 'firstDeclaration', - module: null, - lineStart: 4, - lineEnd: 5, - } ); - expect( name[ 1 ] ).toEqual( { - localName: 'secondDeclaration', - exportName: 'secondDeclaration', - module: null, - lineStart: 4, - lineEnd: 5, - } ); + expect( + parse( ` + /** + * Function declaration example. + */ + function functionDeclaration() {} + + /** + * Class declaration example. + */ + class ClassDeclaration {} + + export { functionDeclaration, ClassDeclaration }; + + /** + * Variable declaration example. + */ + export const variableDeclaration = true; + ` ).map( ( token ) => getExportEntries( token ) ) + ).toEqual( [ + [ + expect.objectContaining( { + localName: 'functionDeclaration', + exportName: 'functionDeclaration', + module: null, + } ), + expect.objectContaining( { + localName: 'ClassDeclaration', + exportName: 'ClassDeclaration', + module: null, + } ), + ], + [ + expect.objectContaining( { + localName: 'variableDeclaration', + exportName: 'variableDeclaration', + module: null, + } ), + ], + ] ); } ); + it( 'named import namespace', () => + expect( + firstExport( + ` + /** + * Internal dependencies + */ + import * as variables from './module-code'; + + export { variables }; + `, + ` + /** + * Function declaration example. + */ + export default function myDeclaration() {} + ` + ) + ).toEqual( [ + expect.objectContaining( { + localName: 'variables', + exportName: 'variables', + module: null, + } ), + ] ) ); + + it( 'named variable', () => + expect( + firstExport( ` + /** + * My declaration example. + */ + export const myDeclaration = true; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'myDeclaration', + exportName: 'myDeclaration', + module: null, + } ), + ] ) ); + + it( 'named variables', () => + expect( + firstExport( ` + /** + * My declaration example. + */ + export const firstDeclaration = true, + secondDeclaration = 42; + ` ) + ).toEqual( [ + expect.objectContaining( { + localName: 'firstDeclaration', + exportName: 'firstDeclaration', + module: null, + } ), + expect.objectContaining( { + localName: 'secondDeclaration', + exportName: 'secondDeclaration', + module: null, + } ), + ] ) ); + it( 'namespace (*)', () => { - const token = require( './fixtures/namespace/exports.json' ); - const name = getExportEntries( token ); - expect( name ).toHaveLength( 1 ); - expect( name[ 0 ] ).toEqual( { - localName: '*', - exportName: null, - module: './namespace-module', - lineStart: 1, - lineEnd: 1, - } ); + expect( + firstExport( + ` + export * from './module-code'; + `, + ` + /** + * Named variable. + */ + export const myVariable = true; + + /** + * Named function. + */ + export const myFunction = () => {}; + + /** + * Named class. + */ + export class MyClass {} + + /** + * Default variable declaration. + */ + export default 42; + ` + ) + ).toEqual( [ + expect.objectContaining( { + localName: '*', + exportName: null, + module: './module-code', + } ), + ] ); } ); } ); diff --git a/packages/docgen/test/get-intermediate-representation.js b/packages/docgen/test/get-intermediate-representation.js index 03cf48008e7ee..43001aaedeeae 100644 --- a/packages/docgen/test/get-intermediate-representation.js +++ b/packages/docgen/test/get-intermediate-representation.js @@ -1,670 +1,719 @@ /** * Internal dependencies */ +const engine = require( '../lib/engine' ); const getIntermediateRepresentation = require( '../lib/get-intermediate-representation' ); +/** + * Parses sample code into testable structure. + * + * @param {string} code Sourcecode to analyze in test. + * @param {string} [importedCode] Sourcecode for module imported in `code`. + */ +const parse = ( code, importedCode ) => + engine( + 'test-code.ts', + code.trim(), + importedCode + ? () => engine( 'module-code.ts', importedCode ).ir + : undefined + ).ir; + describe( 'Intermediate Representation', () => { describe( 'undocumented code', () => { - it( 'default export on multiple lines', () => { - const ir = getIntermediateRepresentation( - null, - require( './fixtures/default-undocumented-nocomments/exports.json' ) - ); - expect( ir ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Undocumented declaration.", - "lineEnd": 3, - "lineStart": 3, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'default export on one line', () => { - const irOneliner = getIntermediateRepresentation( - null, - require( './fixtures/default-undocumented-oneliner/exports.json' ) - ); - expect( irOneliner ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Undocumented declaration.", - "lineEnd": 2, - "lineStart": 2, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'default export on multiple lines', () => + expect( + parse( ` + const myDeclaration = function () {}; + + export default myDeclaration; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Undocumented declaration.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'default export on one line', () => + expect( + parse( ` + // This comment should be ignored. + export default function () {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Undocumented declaration.', + name: 'default', + tags: [], + } ), + ] ) ); } ); describe( 'JSDoc in export statement', () => { describe( 'default export', () => { - it( 'anonymous class', () => { - const irClassAnonymous = getIntermediateRepresentation( - null, - require( './fixtures/default-class-anonymous/exports.json' ) - ); - expect( irClassAnonymous ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Class declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named class', () => { - const irClassNamed = getIntermediateRepresentation( - null, - require( './fixtures/default-class-named/exports.json' ) - ); - expect( irClassNamed ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Class declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'anonymous function', () => { - const irFnAnonymous = getIntermediateRepresentation( - null, - require( './fixtures/default-function-anonymous/exports.json' ) - ); - expect( irFnAnonymous ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named function', () => { - const irFnNamed = getIntermediateRepresentation( - null, - require( './fixtures/default-function-named/exports.json' ) - ); - expect( irFnNamed ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'variable', () => { - const irVar = getIntermediateRepresentation( - null, - require( './fixtures/default-variable/exports.json' ) - ); - expect( irVar ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Variable declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'anonymous class', () => + expect( + parse( ` + /** + * Class declaration example. + */ + export default class {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Class declaration example.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'named class', () => + expect( + parse( ` + /** + * Class declaration example. + */ + export default class ClassDeclaration {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Class declaration example.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'anonymous function', () => + expect( + parse( ` + /** + * Function declaration example. + */ + export default function () {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration example.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'named function', () => + expect( + parse( ` + /** + * Function declaration example. + */ + export default function myDeclaration() {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration example.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'variable', () => + expect( + parse( ` + /** + * Variable declaration example. + */ + export default true; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Variable declaration example.', + name: 'default', + tags: [], + } ), + ] ) ); } ); + describe( 'named export', () => { - it( 'named class', () => { - const irNamedClass = getIntermediateRepresentation( - null, - require( './fixtures/named-class/exports.json' ) - ); - expect( irNamedClass ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "My declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "MyDeclaration", - "path": null, - "tags": Array [ - Object { - "description": "", - "name": "", - "tag": "type", - "type": "MyDeclaration", - }, - ], - }, - ] - ` ); - } ); - it( 'named function', () => { - const irNamedFn = getIntermediateRepresentation( - null, - require( './fixtures/named-function/exports.json' ) - ); - expect( irNamedFn ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "My declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "myDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named variable', () => { - const irNamedVar = getIntermediateRepresentation( - null, - require( './fixtures/named-variable/exports.json' ) - ); - expect( irNamedVar ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "My declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "myDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named variables', () => { - const irNamedVars = getIntermediateRepresentation( - null, - require( './fixtures/named-variables/exports.json' ) - ); - expect( irNamedVars ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "My declaration example.", - "lineEnd": 5, - "lineStart": 4, - "name": "firstDeclaration", - "path": null, - "tags": Array [], - }, - Object { - "description": "My declaration example.", - "lineEnd": 5, - "lineStart": 4, - "name": "secondDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'named class', () => + expect( + parse( ` + /** + * My declaration example. + */ + export class MyDeclaration {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'My declaration example.', + name: 'MyDeclaration', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'MyDeclaration', + }, + ], + } ), + ] ) ); + + it( 'named function', () => + expect( + parse( ` + /** + * My declaration example. + */ + export function myDeclaration() {} + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'My declaration example.', + name: 'myDeclaration', + tags: [], + } ), + ] ) ); + + it( 'named variable', () => + expect( + parse( ` + /** + * My declaration example. + */ + export const myDeclaration = true; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'My declaration example.', + name: 'myDeclaration', + tags: [], + } ), + ] ) ); + + it( 'named variables', () => + expect( + parse( ` + /** + * My declaration example. + */ + export const firstDeclaration = true, + secondDeclaration = 42; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'My declaration example.', + name: 'firstDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'My declaration example.', + name: 'secondDeclaration', + tags: [], + } ), + ] ) ); } ); } ); describe( 'JSDoc in same file', () => { describe( 'default export', () => { - it( 'named class', () => { - const irDefaultId = getIntermediateRepresentation( - null, - require( './fixtures/default-identifier/exports.json' ), - require( './fixtures/default-identifier/ast.json' ) - ); - expect( irDefaultId ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Class declaration example.", - "lineEnd": 6, - "lineStart": 6, - "name": "default", - "path": null, - "tags": Array [ - Object { - "description": "", - "name": "", - "tag": "type", - "type": "ClassDeclaration", - }, - ], - }, - ] - ` ); - } ); - it( 'named function', () => { - const namedExport = require( './fixtures/default-named-export/exports.json' ); - const namedExportAST = require( './fixtures/default-named-export/ast.json' ); - const irDefaultNamed0 = getIntermediateRepresentation( - null, - namedExport[ 0 ], - namedExportAST - ); - expect( irDefaultNamed0 ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "functionDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - const irDefaultNamed1 = getIntermediateRepresentation( - null, - namedExport[ 1 ], - namedExportAST - ); - expect( irDefaultNamed1 ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 6, - "lineStart": 6, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'named class', () => + expect( + parse( ` + /** + * Class declaration example. + */ + class ClassDeclaration {} + + export default ClassDeclaration; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Class declaration example.', + name: 'default', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'ClassDeclaration', + }, + ], + } ), + ] ) ); + + it( 'named function', () => + expect( + parse( ` + /** + * Function declaration example. + */ + export function functionDeclaration() {} + + export default functionDeclaration; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration example.', + name: 'functionDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'Function declaration example.', + name: 'default', + tags: [], + } ), + ] ) ); } ); describe( 'named export', () => { - it( 'named identifier', () => { - const irNamedId = getIntermediateRepresentation( - null, - require( './fixtures/named-identifier/exports.json' ), - require( './fixtures/named-identifier/ast.json' ) - ); - expect( irNamedId ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "My declaration example.", - "lineEnd": 6, - "lineStart": 6, - "name": "myDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named identifier with destructuring', () => { - const irNamedIdDestructuring = getIntermediateRepresentation( - null, - require( './fixtures/named-identifier-destructuring/exports.json' ), - require( './fixtures/named-identifier-destructuring/ast.json' ) - ); - expect( irNamedIdDestructuring ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "My declaration example.", - "lineEnd": 6, - "lineStart": 6, - "name": "myDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named identifiers', () => { - const irIds = getIntermediateRepresentation( - null, - require( './fixtures/named-identifiers/exports.json' ), - require( './fixtures/named-identifiers/ast.json' ) - ); - expect( irIds ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 16, - "lineStart": 16, - "name": "functionDeclaration", - "path": null, - "tags": Array [], - }, - Object { - "description": "Variable declaration example.", - "lineEnd": 16, - "lineStart": 16, - "name": "variableDeclaration", - "path": null, - "tags": Array [], - }, - Object { - "description": "Class declaration example.", - "lineEnd": 16, - "lineStart": 16, - "name": "ClassDeclaration", - "path": null, - "tags": Array [ - Object { - "description": "", - "name": "", - "tag": "type", - "type": "ClassDeclaration", - }, - ], - }, - ] - ` ); - } ); + it( 'named identifier', () => + expect( + parse( ` + /** + * My declaration example. + */ + function myDeclaration() {} + + export { myDeclaration }; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'My declaration example.', + name: 'myDeclaration', + tags: [], + } ), + ] ) ); + + it( 'named identifier with destructuring', () => + expect( + parse( ` + /** + * My declaration example. + */ + const { someDeclaration } = { someDeclaration: () => {} }; + + export { someDeclaration as myDeclaration }; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'My declaration example.', + name: 'myDeclaration', + tags: [], + } ), + ] ) ); + + it( 'named identifiers', () => + expect( + parse( ` + /** + * Function declaration example. + */ + function functionDeclaration() {} + + /** + * Class declaration example. + */ + class ClassDeclaration {} + + /** + * Variable declaration example. + */ + const variableDeclaration = true; + + export { functionDeclaration, variableDeclaration, ClassDeclaration }; + ` ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration example.', + name: 'functionDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'Variable declaration example.', + name: 'variableDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'Class declaration example.', + name: 'ClassDeclaration', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'ClassDeclaration', + }, + ], + } ), + ] ) ); + it( 'named identifiers and inline', () => { - const foo = require( './fixtures/named-identifiers-and-inline/exports.json' ); - const bar = require( './fixtures/named-identifiers-and-inline/ast.json' ); - const irIdInline0 = getIntermediateRepresentation( - null, - foo[ 0 ], - bar - ); - expect( irIdInline0 ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 11, - "lineStart": 11, - "name": "functionDeclaration", - "path": null, - "tags": Array [], - }, - Object { - "description": "Class declaration example.", - "lineEnd": 11, - "lineStart": 11, - "name": "ClassDeclaration", - "path": null, - "tags": Array [ - Object { - "description": "", - "name": "", - "tag": "type", - "type": "ClassDeclaration", - }, - ], - }, - ] - ` ); - const irIdInline1 = getIntermediateRepresentation( - null, - foo[ 1 ], - bar + const { + ast, + tokens: [ firstExport, secondExport ], + } = engine( + 'test-code.ts', + ` + /** + * Function declaration example. + */ + function functionDeclaration() {} + + /** + * Class declaration example. + */ + class ClassDeclaration {} + + export { functionDeclaration, ClassDeclaration }; + + /** + * Variable declaration example. + */ + export const variableDeclaration = true; + ` ); - expect( irIdInline1 ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Variable declaration example.", - "lineEnd": 16, - "lineStart": 16, - "name": "variableDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); + + expect( + getIntermediateRepresentation( '', firstExport, ast ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration example.', + name: 'functionDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'Class declaration example.', + name: 'ClassDeclaration', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'ClassDeclaration', + }, + ], + } ), + ] ); + + expect( + getIntermediateRepresentation( '', secondExport, ast ) + ).toEqual( [ + expect.objectContaining( { + description: 'Variable declaration example.', + name: 'variableDeclaration', + tags: [], + } ), + ] ); } ); } ); } ); describe( 'JSDoc in module dependency', () => { describe( 'named export', () => { - it( 'named import', () => { - const ir = getIntermediateRepresentation( - null, - require( './fixtures/named-import-named/exports.json' ), - { body: [] }, - () => require( './fixtures/named-identifiers/ir.json' ) - ); - expect( ir ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration example.", - "lineEnd": 2, - "lineStart": 2, - "name": "functionDeclaration", - "path": null, - "tags": Array [], - }, - Object { - "description": "Variable declaration example.", - "lineEnd": 3, - "lineStart": 3, - "name": "variableDeclaration", - "path": null, - "tags": Array [], - }, - Object { - "description": "Class declaration example.", - "lineEnd": 4, - "lineStart": 4, - "name": "ClassDeclaration", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'named import', () => + expect( + parse( + ` + export { + functionDeclaration, + variableDeclaration, + ClassDeclaration, + } from './module-code'; + `, + ` + /** + * Function declaration example. + */ + function functionDeclaration() {} + + /** + * Class declaration example. + */ + class ClassDeclaration {} + + /** + * Variable declaration example. + */ + const variableDeclaration = true; + + export { functionDeclaration, variableDeclaration, ClassDeclaration }; + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration example.', + name: 'functionDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'Variable declaration example.', + name: 'variableDeclaration', + tags: [], + } ), + expect.objectContaining( { + description: 'Class declaration example.', + name: 'ClassDeclaration', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'ClassDeclaration', + }, + ], + } ), + ] ) ); } ); describe( 'named default export', () => { - it( 'default', () => { - const irNamedDefault = getIntermediateRepresentation( - null, - require( './fixtures/named-default/exports.json' ), - { body: [] }, - () => require( './fixtures/named-default/module-ir.json' ) - ); - expect( irNamedDefault ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Module declaration.", - "lineEnd": 1, - "lineStart": 1, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'renamed', () => { - const irNamedDefaultExported = getIntermediateRepresentation( - null, - require( './fixtures/named-default-exported/exports.json' ), - { body: [] }, - () => require( './fixtures/named-default/module-ir.json' ) - ); - expect( irNamedDefaultExported ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Module declaration.", - "lineEnd": 1, - "lineStart": 1, - "name": "moduleName", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'default', () => + expect( + parse( + ` + export { default } from './module-code'; + `, + ` + /** + * Module declaration. + */ + export default function () {} + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Module declaration.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'renamed', () => + expect( + parse( + ` + export { default as moduleName } from './module-code'; + `, + ` + /** + * Module declaration. + */ + export default function () {} + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Module declaration.', + name: 'moduleName', + tags: [], + } ), + ] ) ); } ); describe( 'namespace export', () => { - const getModule = () => - require( './fixtures/namespace/module-ir.json' ); - it( 'exports', () => { - const irNamespace = getIntermediateRepresentation( - null, - require( './fixtures/namespace/exports.json' ), - { body: [] }, - getModule - ); - expect( irNamespace ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Named class.", - "lineEnd": 1, - "lineStart": 1, - "name": "MyClass", - "path": null, - "tags": Array [], - }, - Object { - "description": "Named function.", - "lineEnd": 1, - "lineStart": 1, - "name": "myFunction", - "path": null, - "tags": Array [], - }, - Object { - "description": "Named variable.", - "lineEnd": 1, - "lineStart": 1, - "name": "myVariable", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'exports with comment', () => { - const irNamespaceCommented = getIntermediateRepresentation( - null, - require( './fixtures/namespace-commented/exports.json' ), - { body: [] }, - getModule - ); - expect( irNamespaceCommented ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Named class.", - "lineEnd": 4, - "lineStart": 4, - "name": "MyClass", - "path": null, - "tags": Array [], - }, - Object { - "description": "Named function.", - "lineEnd": 4, - "lineStart": 4, - "name": "myFunction", - "path": null, - "tags": Array [], - }, - Object { - "description": "Named variable.", - "lineEnd": 4, - "lineStart": 4, - "name": "myVariable", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'exports', () => + expect( + parse( + ` + export * from './module-code'; + `, + ` + /** + * Named variable. + */ + export const myVariable = true; + + /** + * Named function. + */ + export const myFunction = () => {}; + + /** + * Named class. + */ + export class MyClass {} + + /** + * Default variable declaration. + */ + export default 42; + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Named variable.', + name: 'myVariable', + tags: [], + } ), + expect.objectContaining( { + description: 'Named function.', + name: 'myFunction', + tags: [], + } ), + expect.objectContaining( { + description: 'Named class.', + name: 'MyClass', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'MyClass', + }, + ], + } ), + ] ) ); + + it( 'exports with comment', () => + expect( + parse( + ` + /** + * This comment should be ignored. + */ + export * from './module-code'; + `, + ` + /** + * Named variable. + */ + export const myVariable = true; + + /** + * Named function. + */ + export const myFunction = () => {}; + + /** + * Named class. + */ + export class MyClass {} + + /** + * Default variable declaration. + */ + export default 42; + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Named variable.', + name: 'myVariable', + tags: [], + } ), + expect.objectContaining( { + description: 'Named function.', + name: 'myFunction', + tags: [], + } ), + expect.objectContaining( { + description: 'Named class.', + name: 'MyClass', + tags: [ + { + description: '', + name: '', + tag: 'type', + type: 'MyClass', + }, + ], + } ), + ] ) ); } ); } ); describe( 'JSDoc in module dependency through import', () => { describe( 'default export', () => { - it( 'default import', () => { - const irDefault = getIntermediateRepresentation( - null, - require( './fixtures/default-import-default/exports.json' ), - require( './fixtures/default-import-default/ast.json' ), - () => - require( './fixtures/default-import-default/module-ir.json' ) - ); - expect( irDefault ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration.", - "lineEnd": 3, - "lineStart": 3, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); - it( 'named import', () => { - const irNamed = getIntermediateRepresentation( - null, - require( './fixtures/default-import-named/exports.json' ), - require( './fixtures/default-import-named/ast.json' ), - () => - require( './fixtures/default-import-named/module-ir.json' ) - ); - expect( irNamed ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Function declaration.", - "lineEnd": 3, - "lineStart": 3, - "name": "default", - "path": null, - "tags": Array [], - }, - ] - ` ); - } ); + it( 'default import', () => + expect( + parse( + ` + /** + * Internal dependencies + */ + import fnDeclaration from './module-code'; + + export default fnDeclaration; + `, + ` + /** + * Function declaration. + */ + function functionDeclaration() {} + + export default functionDeclaration; + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration.', + name: 'default', + tags: [], + } ), + ] ) ); + + it( 'named import', () => + expect( + parse( + ` + /** + * Internal dependencies + */ + import { functionDeclaration as fnDeclaration } from './module-code'; + + export default fnDeclaration; + `, + ` + /** + * Function declaration. + */ + function functionDeclaration() {} + + export { functionDeclaration }; + ` + ) + ).toEqual( [ + expect.objectContaining( { + description: 'Function declaration.', + name: 'default', + tags: [], + } ), + ] ) ); } ); describe( 'named export', () => { it( 'namespace import', () => { - const getModuleImportNamespace = ( filePath ) => { - if ( filePath === './named-import-namespace-module' ) { - return require( './fixtures/named-import-namespace/module-ir.json' ); - } - return require( './fixtures/default-function/ir.json' ); - }; - const ir = getIntermediateRepresentation( - null, - require( './fixtures/named-import-namespace/exports.json' ), - require( './fixtures/named-import-namespace/ast.json' ), - getModuleImportNamespace - ); - expect( ir ).toMatchInlineSnapshot( ` - Array [ - Object { - "description": "Undocumented declaration.", - "lineEnd": 3, - "lineStart": 3, - "name": "variables", - "path": null, - "tags": Array [], - }, - ] - ` ); + const dependency = engine( + 'named-import-namespace-module.ts', + `export { default as controls } from './default-function-named';`, + () => + parse( ` + /** + * Function declaration example. + */ + export default function myDeclaration() {} + ` ) + ).ir; + + expect( + engine( + 'test-code.ts', + ` + /** + * Internal dependencies + */ + import * as variables from './named-import-namespace-module'; + + export { variables }; + `, + () => dependency + ).ir + ).toEqual( [ + expect.objectContaining( { + description: 'Undocumented declaration.', + name: 'variables', + tags: [], + } ), + ] ); } ); } ); } ); diff --git a/packages/docgen/test/get-type-annotation.js b/packages/docgen/test/get-type-annotation.js index c0e07ce0ab554..13ff923f22990 100644 --- a/packages/docgen/test/get-type-annotation.js +++ b/packages/docgen/test/get-type-annotation.js @@ -1,24 +1,15 @@ /** * Internal dependencies */ -const getTypeAnnotation = require( '../lib/get-type-annotation' ); const engine = require( '../lib/engine' ); +const getTypeAnnotation = require( '../lib/get-type-annotation' ); -const getSimpleTypeNode = require( './fixtures/type-annotations/simple-types/get-node' ); -const getArraysGenericTypesUnionsAndIntersctionsNode = require( './fixtures/type-annotations/arrays-generic-types-unions-intersections/get-node' ); -const getLiteralsNode = require( './fixtures/type-annotations/literal-values/get-node' ); -const getTypeLiteralNode = require( './fixtures/type-annotations/type-literals/get-node' ); -const getNamedExportNode = require( './fixtures/type-annotations/named-export/get-node' ); -const getExportedVariableDeclarationNode = require( './fixtures/type-annotations/exported-variable-declaration/get-node' ); -const getImportsParameterizedRestOperatorPredicateIndexerTypeNode = require( './fixtures/type-annotations/imports-parameterized-rest-operator-predicate-indexers/get-node' ); -const getMissingTypesNode = require( './fixtures/type-annotations/missing-types/get-node' ); -const getArrowFunctionNode = require( './fixtures/type-annotations/arrow-function/get-node' ); -const getArrayDestructuringArrayTypeNode = require( './fixtures/type-annotations/array-destructuring-array-type/get-node' ); -const getArrayDestructuringTupleTypeNode = require( './fixtures/type-annotations/array-destructuring-tuple-type/get-node' ); -const getArrayDestructuringAnyOtherTypeNode = require( './fixtures/type-annotations/array-destructuring-any-other-type/get-node' ); -const getObjectDestructuringTypeLiteralNode = require( './fixtures/type-annotations/object-destructuring-object-literal-type/get-node' ); -const getAssignmentPatternNode = require( './fixtures/type-annotations/assignment-pattern/get-node' ); -const getExportedVariableDeclarationStaticNode = require( './fixtures/type-annotations/exported-variable-declaration-statics/get-node' ); +/** + * Generate the AST necessary to assert inferred types. + * + * @param {string} code - Actual source code to parse. + */ +const parse = ( code ) => engine( 'test-code.ts', code ).ast.body[ 0 ]; describe( 'Type annotations', () => { it( 'are taken from JSDoc if any', () => { @@ -47,237 +38,308 @@ describe( 'Type annotations', () => { description: 'A foo parameter', }; - const returnTag = { - tag: 'return', - type: '', - name: 'My', - description: 'favorite return', - }; - describe( 'simple types', () => { const keywordTypes = [ - [ 'TSAnyKeyword', 'any' ], - [ 'TSBigIntKeyword', 'BigInt' ], - [ 'TSBooleanKeyword', 'boolean' ], - [ 'TSNeverKeyword', 'never' ], - [ 'TSNullKeyword', 'null' ], - [ 'TSNumberKeyword', 'number' ], - [ 'TSObjectKeyword', 'object' ], - [ 'TSStringKeyword', 'string' ], - [ 'TSSymbolKeyword', 'symbol' ], - [ 'TSUndefinedKeyword', 'undefined' ], - [ 'TSUnknownKeyword', 'unknown' ], - [ 'TSVoidKeyword', 'void' ], + 'any', + 'BigInt', + 'boolean', + 'never', + 'null', + 'number', + 'object', + 'string', + 'symbol', + 'undefined', + 'unknown', + 'void', ]; it.each( keywordTypes )( `should get the parameter type for an %s`, - ( paramType, expected ) => { - const node = getSimpleTypeNode( { paramType } ); - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( - expected - ); + ( typeName ) => { + expect( + getTypeAnnotation( + { tag: 'param', name: 'foo' }, + parse( `function fn(foo: ${ typeName }): any {}` ), + 0 + ) + ).toBe( typeName ); } ); it.each( keywordTypes )( `should get the return type for an %s`, - ( returnType, expected ) => { - const node = getSimpleTypeNode( { returnType } ); - expect( getTypeAnnotation( returnTag, node, 0 ) ).toBe( - expected - ); + ( typeName ) => { + expect( + getTypeAnnotation( + { tag: 'return' }, + parse( `function fn(foo: any): ${ typeName } {}` ) + ) + ).toBe( typeName ); } ); } ); describe( 'arrays, applied generic types, unions, intersections', () => { - const node = getArraysGenericTypesUnionsAndIntersctionsNode(); + const node = parse( ` + function fn( foo: MyType< string | number >[] ): MyType< string & number >[] { + return []; + } + ` ); it( 'should get the param type', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( - 'MyType< string | number >[]' - ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( 'MyType< string | number >[]' ); } ); it( 'should get the return type', () => { - expect( getTypeAnnotation( returnTag, node, 0 ) ).toBe( + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBe( 'MyType< string & number >[]' ); } ); } ); describe( 'literal values', () => { - describe.each( [ - [ 'param', paramTag ], - [ 'return', returnTag ], - ] )( '%s', ( _, tag ) => { - it.each( [ - [ 'StringLiteral', 'a-string-literal', "'a-string-literal'" ], - [ 'BigIntLiteral', 1000, '1000n' ], - [ 'BooleanLiteral', true, 'true' ], - [ 'NumericLiteral', 1000, '1000' ], - ] )( - 'should handle %s', - ( literalType, literalValue, literalResult ) => { - const node = getLiteralsNode( { - literalType, - literalValue, - } ); - expect( getTypeAnnotation( tag, node, 0 ) ).toBe( - literalResult - ); - } - ); - } ); + it.each( [ "'a-string-literal'", '1000n', 'true', '1000' ] )( + 'should handle %s', + ( literal ) => { + const node = parse( ` + function fn( foo: ${ literal } ): ${ literal } { + return BigInt( '1000' ) as ${ literal }; + } + ` ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( literal ); + } + ); + + it.each( [ "'a-string-literal'", '1000n', 'true', '1000' ] )( + 'should handle %s in the return', + ( literal ) => { + const node = parse( ` + function fn( foo: ${ literal } ): ${ literal } { + return BigInt( '1000' ) as ${ literal }; + } + ` ); + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBe( + literal + ); + } + ); } ); describe( 'type literals', () => { - const node = getTypeLiteralNode(); + const node = parse( ` + function fn( foo: { + ( bar: string ): void; + bar: string; + optionalBar?: 'left' | 'right'; + [ key: number ]: string; + } ): { + ( bar: string ): void; + bar: string; + optionalBar?: 'left' | 'right'; + [ key: number ]: string; + } {} + ` ); it( 'should get the param type literal annotation', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( "{ ( bar: string ): void; bar: string; optionalBar?: 'left' | 'right'; [ key: number ]: string; }" ); } ); it( 'should get the return type literal annotation', () => { - expect( getTypeAnnotation( returnTag, node, 0 ) ).toBe( + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBe( "{ ( bar: string ): void; bar: string; optionalBar?: 'left' | 'right'; [ key: number ]: string; }" ); } ); } ); describe( 'named export', () => { - const node = getNamedExportNode(); + const node = parse( `export function fn( foo: string ): string {}` ); it( 'should get the param type', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( 'string' ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( 'string' ); } ); it( 'should get the return type', () => { - expect( getTypeAnnotation( returnTag, node, 0 ) ).toBe( 'string' ); + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBe( + 'string' + ); } ); } ); describe( 'exported variable declaration', () => { - const node = getExportedVariableDeclarationNode(); - + const node = parse( `export const fn = ( foo: string ): void => {};` ); it( 'should get the param type', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( 'string' ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( 'string' ); } ); it( 'should get the return type', () => { - expect( getTypeAnnotation( returnTag, node, 0 ) ).toBe( 'void' ); + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBe( + 'void' + ); } ); } ); describe( 'imports, parameterized types, rest types, operator types, type predicates, index accessed types', () => { - const node = getImportsParameterizedRestOperatorPredicateIndexerTypeNode(); + const node = parse( ` + function fn( + foo: import('react').bar.baz.types.ComponentType[ 'displayName' ], + ...rest: [ string | number, ...( keyof constant ) ] + ): foo is string {} + ` ); it( 'should get the index accessed import type', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( "import( 'react' ).bar.baz.types.ComponentType[ 'displayName' ]" ); } ); it( 'should get the parameterized tuple rest type', () => { expect( - getTypeAnnotation( { ...paramTag, name: 'rest' }, node, 1 ) + getTypeAnnotation( { tag: 'param', name: 'rest' }, node, 1 ) ).toBe( '[ string | number, ...( keyof constant ) ]' ); } ); it( 'should get the type predicate return type', () => { - expect( getTypeAnnotation( returnTag, node, 1 ) ).toBe( + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBe( 'foo is string' ); } ); } ); describe( 'missing types', () => { - const node = getMissingTypesNode(); + const node = parse( `function fn( foo ) {}` ); it( 'should return empty value if there is no return type', () => { - expect( getTypeAnnotation( returnTag, node, 0 ) ).toBeFalsy(); + expect( getTypeAnnotation( { tag: 'return' }, node ) ).toBeFalsy(); } ); it( 'should return empty value if there is no param type', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBeFalsy(); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBeFalsy(); } ); } ); describe( 'function argument array-destructuring', () => { describe( 'array-type', () => { - const node = getArrayDestructuringArrayTypeNode(); + const node = parse( ` + function fn< T >( [ head ]: T[] ): T { + return head; + } + ` ); it( 'should grab the whole type for the unqualified name', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( 'T[]' ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( 'T[]' ); } ); it( 'should get the individual type for the qualified name', () => { expect( - getTypeAnnotation( { ...paramTag, name: 'foo.0' }, node, 0 ) + getTypeAnnotation( + { tag: 'param', name: 'foo.0' }, + node, + 0 + ) ).toBe( 'T' ); } ); } ); describe( 'tuple-type', () => { - const node = getArrayDestructuringTupleTypeNode(); + const node = parse( ` + function second< T, S = T >( [ head, sec ]: [ T, S ] ): S { + return sec; + } + ` ); it( 'should grab the whole type for the unqualified name', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( - '[ T, S ]' - ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( '[ T, S ]' ); } ); it( 'should get the individual type for the qualified name', () => { expect( - getTypeAnnotation( { ...paramTag, name: 'foo.1' }, node, 0 ) + getTypeAnnotation( + { tag: 'param', name: 'foo.1' }, + node, + 0 + ) ).toBe( 'S' ); } ); } ); describe( 'any-other-type', () => { - const node = getArrayDestructuringAnyOtherTypeNode(); + const node = parse( ` + function fn( [ first, second ]: ( T & S ) | V ): S { + return second; + } + ` ); it( 'should get the full type name for the unqualified name', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( - '( T & S ) | V' - ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( '( T & S ) | V' ); } ); it( 'should get the full type with a qualification for the qualified name', () => { expect( - getTypeAnnotation( { ...paramTag, name: 'foo.1' }, node, 0 ) + getTypeAnnotation( + { tag: 'param', name: 'foo.1' }, + node, + 0 + ) ).toBe( '( ( T & S ) | V )[ 1 ]' ); } ); } ); } ); describe( 'arrow function parameters', () => { - const node = getArrowFunctionNode(); + const node = parse( ` + export const fn = ( + callback: ( foo: string, ...rest: any[] ) => GenericType< T > + ): void => {}; + ` ); it( 'should correctly format the arrow function', () => { expect( - getTypeAnnotation( { ...paramTag, name: 'callback' }, node, 0 ) + getTypeAnnotation( { tag: 'param', name: 'callback' }, node, 0 ) ).toBe( '( foo: string, ...rest: any[] ) => GenericType< T >' ); } ); } ); describe( 'function argument object destructuring', () => { describe( 'type literal', () => { - const node = getObjectDestructuringTypeLiteralNode(); + const node = parse( ` + function fn( { foo, ...rest }: { foo: string } ): string { + return foo; + } + ` ); it( 'should get the full type for the param', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( - '{ foo: string; }' - ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( '{ foo: string; }' ); } ); it( 'should get the member type for the param', () => { expect( getTypeAnnotation( - { ...paramTag, name: 'props.foo' }, + { tag: 'param', name: 'props.foo' }, node, 0 ) @@ -297,21 +359,32 @@ describe( 'Type annotations', () => { } ); describe( 'assignment pattern', () => { - const node = getAssignmentPatternNode(); + const node = parse( ` + function fn( [ foo ]: string = '' ): string { + return foo; + } + ` ); it( 'should get the type of the assignment pattern', () => { - expect( getTypeAnnotation( paramTag, node, 0 ) ).toBe( 'string' ); + expect( + getTypeAnnotation( { tag: 'param', name: 'foo' }, node, 0 ) + ).toBe( 'string' ); } ); it( 'should get the type of the assignment pattern for array destructuring', () => { expect( - getTypeAnnotation( { ...paramTag, name: 'props.0' }, node, 0 ) + getTypeAnnotation( { tag: 'param', name: 'props.0' }, node, 0 ) ).toBe( '( string )[ 0 ]' ); } ); } ); describe( 'static exported variable', () => { - const node = getExportedVariableDeclarationStaticNode(); + const node = parse( ` + /** + * This is a description of the variable + */ + export const foo: ( string | number )[] = []; + ` ); it( 'should get the type of the variable', () => { expect( getTypeAnnotation( { tag: 'type' }, node, 0 ) ).toBe(