├── .gitignore ├── lib ├── index.js └── rules │ └── no-floating-promise.js ├── package.json ├── README.md └── tests ├── lib └── rules │ └── no-floating-promise.js └── fixtures └── parsers └── no-floating-promise ├── no-floating-promise-argument.js ├── floating-promise-any.js ├── floating-promise-argument.js ├── floating-promise-typed-identifier.js ├── floating-promise-typed-expression.js └── no-floating-promise-typed.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Detects missing await on async function calls 3 | * @author Sebastien Guillemot 4 | */ 5 | "use strict"; 6 | 7 | //------------------------------------------------------------------------------ 8 | // Requirements 9 | //------------------------------------------------------------------------------ 10 | 11 | var requireIndex = require("requireindex"); 12 | 13 | //------------------------------------------------------------------------------ 14 | // Plugin Definition 15 | //------------------------------------------------------------------------------ 16 | 17 | 18 | // import all rules in lib/rules 19 | module.exports.rules = requireIndex(__dirname + "/rules"); 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-plugin-no-floating-promise", 3 | "version": "2.0.0", 4 | "description": "Detects missing await on async function calls", 5 | "keywords": [ 6 | "eslint", 7 | "eslintplugin", 8 | "eslint-plugin", 9 | "Flow", 10 | "async" 11 | ], 12 | "author": "Sebastien Guillemot", 13 | "main": "lib/index.js", 14 | "files": [ 15 | "lib" 16 | ], 17 | "scripts": { 18 | "test": "mocha tests --recursive" 19 | }, 20 | "dependencies": { 21 | "requireindex": "1.2.0" 22 | }, 23 | "devDependencies": { 24 | "eslint": "~9.0.0", 25 | "mocha": "~8.1.1" 26 | }, 27 | "engines": { 28 | "node": ">=0.10.0" 29 | }, 30 | "license": "MIT", 31 | "repository": { 32 | "type": "git", 33 | "url": "git+https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise.git" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/rules/no-floating-promise.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Rule to avoid "floating" promises 3 | * @author Sebastien Guillemot 4 | */ 5 | "use strict"; 6 | 7 | //------------------------------------------------------------------------------ 8 | // Helpers 9 | //------------------------------------------------------------------------------ 10 | 11 | const getName = (node) => { 12 | if (node.name) { 13 | return node.name; 14 | } 15 | if (node.id) { 16 | return node.id.name; 17 | } 18 | 19 | return null; 20 | }; 21 | 22 | /** 23 | * recursively go up levels in scope until we find our variable declaration 24 | * @param {Scope} scope - starting scope for search 25 | * @param {string} name - name of literal to look for 26 | * @returns {Variable|null|void} variable corresponding to literal 27 | */ 28 | function findInScope(scope, name) { 29 | if (name === null || typeof name === "undefined" || scope === null || typeof scope === "undefined") { 30 | return null; 31 | } 32 | const definition = scope.set.get(name); 33 | 34 | if (definition === null || typeof definition === "undefined") { 35 | return findInScope(scope.upper, name); 36 | } 37 | 38 | if (definition.defs.length === 0) { 39 | return null; 40 | } 41 | if (getName(definition.defs[0].node) === name) { 42 | const subDef = definition.defs[0]; 43 | 44 | if (subDef === null || typeof subDef === "undefined") { 45 | return null; 46 | } 47 | 48 | return subDef.node; 49 | } 50 | 51 | for (const variable of scope.variables) { 52 | for (const identifier of variable.identifiers) { 53 | if (getName(identifier) === name) { 54 | return identifier; 55 | } 56 | } 57 | } 58 | 59 | return null; 60 | } 61 | 62 | /** 63 | * Gets a string representation of a type if one exists 64 | * @param {*} type - object representing a type 65 | * @returns {string|null|void} type if one exists 66 | */ 67 | function getTypeAnnotation(type) { 68 | if (type === null || type === undefined) { 69 | return undefined; 70 | } 71 | if (type.typeAnnotation) { 72 | return getTypeAnnotation(type.typeAnnotation); 73 | } 74 | 75 | if (type.returnType) { 76 | return getTypeAnnotation(type.returnType); 77 | } 78 | 79 | return getName(type); 80 | } 81 | 82 | //------------------------------------------------------------------------------ 83 | // Rule Definition 84 | //------------------------------------------------------------------------------ 85 | 86 | module.exports = { 87 | meta: { 88 | type: "suggestion", 89 | 90 | docs: { 91 | description: "disallow floating promises", 92 | category: "Possible Errors", 93 | recommended: false, 94 | url: "https://eslint.org/docs/rules/no-floating-promise" 95 | }, 96 | 97 | schema: [], 98 | 99 | fixable: "code", 100 | 101 | messages: { 102 | foundFloating: "Floating promises can lead to unexpected scheduling." 103 | } 104 | }, 105 | 106 | create(context) { 107 | return { 108 | 109 | /* 110 | * Note: CallExpression does not match on "await foo()" as this is an AwaitExpression 111 | * so this condition already filters out non-floating promises 112 | */ 113 | "ExpressionStatement > CallExpression"(node) { 114 | // need this indirection to handle cases like foo.bar(); 115 | const callee = node.parent.expression.callee; 116 | 117 | // handle anonymously function calls 118 | if ( 119 | callee.type === "ArrowFunctionExpression" || 120 | callee.type === "FunctionExpression") { 121 | if (callee.async || getTypeAnnotation(callee.returnType) === "Promise") { 122 | context.report({ 123 | fix(fixer) { 124 | return fixer.replaceText(node, `await ${context.sourceCode.getText(node)}`); 125 | }, 126 | loc: node.loc, 127 | messageId: "foundFloating", 128 | node 129 | }); 130 | } 131 | } 132 | 133 | if (callee.type === "MemberExpression") { 134 | return; 135 | 136 | /** 137 | * Note: most likely you will fail to find this variable in scope 138 | * since its scope is most likely inside a class 139 | * 140 | * theoretically you would look up the typeAnnotation of node.callee.object 141 | * and then look at the type of callee.property inside it 142 | * however in most cases this won't really work since definitions will cross file boundaries 143 | */ 144 | } 145 | 146 | // handle named function calls 147 | if (callee.type === "Identifier") { 148 | const variable = findInScope(context.sourceCode.getScope(node), callee.name); 149 | if (variable === null || typeof variable === "undefined") { 150 | return; 151 | } 152 | 153 | if (variable.async || getTypeAnnotation(variable) === "Promise") { 154 | context.report({ 155 | fix(fixer) { 156 | return fixer.replaceText(node, `await ${context.sourceCode.getText(node)}`); 157 | }, 158 | loc: node.loc, 159 | messageId: "foundFloating", 160 | node 161 | }); 162 | } 163 | } 164 | } 165 | }; 166 | } 167 | }; 168 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-no-floating-promise 2 | 3 | Detects missing await on async function calls 4 | 5 | **STOP**: Are you a Flow or a Typescript user? 6 | Prefer these: 7 | - Flow: [link](https://github.com/facebook/flow/pull/8482) 8 | - Typescript: [link](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md) 9 | 10 | 11 | ## Installation 12 | 13 | You'll first need to install [ESLint](http://eslint.org): 14 | 15 | ``` 16 | $ npm i eslint --save-dev 17 | ``` 18 | 19 | Next, install `eslint-plugin-no-floating-promise`: 20 | 21 | ``` 22 | $ npm install eslint-plugin-no-floating-promise --save-dev 23 | ``` 24 | 25 | **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-no-floating-promise` globally. 26 | 27 | ## Usage 28 | 29 | Add `no-floating-promise` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: 30 | 31 | ```json 32 | { 33 | "plugins": [ 34 | "no-floating-promise" 35 | ] 36 | } 37 | ``` 38 | 39 | 40 | Then configure the rules you want to use under the rules section. 41 | 42 | ```json 43 | { 44 | "rules": { 45 | "no-floating-promise/no-floating-promise": 2 46 | } 47 | } 48 | ``` 49 | 50 | If you're using flat config (`eslint.config.js`), which is default configuration format for eslint since `v.9.0.0`: 51 | 52 | ```js 53 | const noFloatingPromise = require("eslint-plugin-no-floating-promise"); 54 | 55 | module.exports = [ 56 | { 57 | plugins: { 58 | "no-floating-promise": noFloatingPromise, 59 | }, 60 | rules: { 61 | "no-floating-promise/no-floating-promise": 2 62 | } 63 | } 64 | ]; 65 | ``` 66 | 67 | # Rule definition 68 | 69 | _The `--fix` option on the command line automatically fixes problems reported by this rule._ 70 | 71 | Promises that are never awaited can cause unexpected behavior because they may be scheduled to execute at an unexpected time. 72 | 73 | It's easy to accidentally make this mistake. For example, suppose we have the code 74 | 75 | ```js 76 | function writeToDb() { 77 | // synchronously write to DB 78 | } 79 | writeToDb(); 80 | ``` 81 | 82 | but the code gets refactored so that writing to the database is asynchronous. 83 | 84 | ```js 85 | async function writeToDb() { 86 | // asynchronously write to DB 87 | } 88 | writeToDb(); // <- note we have no await here but probably the user intended to await on this! 89 | ``` 90 | 91 | ## Rule Details 92 | 93 | This rule will fire for any call to an `async` function that both 94 | 95 | * not used (not assigned to a variable, not the return type of a function, etc.) 96 | * not awaited on 97 | 98 | Examples of **incorrect** code for this rule: 99 | 100 | ```js 101 | /*eslint no-floating-promise: "error"*/ 102 | 103 | async function foo() {} 104 | foo(); 105 | 106 | (async () => 5)(); 107 | 108 | // note: function is not async but a Promise return type is specified 109 | function foo(): Promise { return Promise.resolve(); }; 110 | foo(); 111 | ``` 112 | 113 | Examples of **correct** code for this rule: 114 | 115 | ```js 116 | /*eslint no-floating-promise: "error"*/ 117 | 118 | async function foo() {} 119 | await foo(); 120 | 121 | await (async () => 5)(); 122 | 123 | // note: function is not async but a Promise return type is specified 124 | function foo(): Promise { return Promise.resolve(); }; 125 | await foo(); 126 | 127 | // note: promise is not awaited, but it is chained with a 'then' 128 | async function foo() {} 129 | foo().then(() => {}); 130 | ``` 131 | 132 | You may catch additional errors by combining this rule with `no-unused-expression`. 133 | 134 | For example the following will not be considered an error by this plugin, but `no-unused-expression` will complain that `fooResult` is never used. 135 | 136 | ```js 137 | async function foo() {} 138 | const fooResult = foo(); 139 | ``` 140 | 141 | ## When Not To Use It 142 | 143 | If you often make use of asynchronous functions were you explicitly do not want to await on them. 144 | 145 | # Notable design decisions 146 | 147 | ## Promises returned by non-async functions 148 | 149 | It's possible for a function to return a promise and not be async (as seen in test cases for this rule). My rule can leverage type annotations to detect these cases but if no type annotation is present, then no error is reported. We could modify this rule to traverse into the AST to see if the return is a promise or not but this sounds more expensive and would still not catch all cases so I didn't include this logic. 150 | 151 | Additionally, TypeAnnotations are only generated for explicit Flow types so this rule can't take advantage of Flow inference. You could argue this rule would be more effective if implemented directly in Flow but this rule can still catch cases for vanilla Javascript so it didn't feel right to make Flow a dependency for this kind of linting. 152 | 153 | ## Scope of the rule 154 | 155 | Currently using `then` or `catch` silences this rule 156 | ```js 157 | async function foo() {} 158 | foo().then(() => {}); 159 | ``` 160 | 161 | You could argue this is desired since it avoids false-positive where developers explicitly do not want to await. I'm open to feedback about whether or not people want this behavior. 162 | 163 | ## Missing `await` in non-async context 164 | 165 | Right now my rule reports an error in the following case 166 | ```js 167 | async function foo() {} 168 | function bar() { 169 | foo(); 170 | } 171 | ``` 172 | 173 | However, adding an `await` here is not possible because `bar` is not an async function. In fact, my auto-fix rule would add an `await` in front of `foo` which would result in a compiler error. 174 | 175 | However, likely this actually is an error and the user actually should make `bar` an async function. However, I am open to disabling this rule in this context if that's what people want. 176 | 177 | # Limitations 178 | 179 | 1) It cannot make use of Flow inference (you need to explicitly specify types) 180 | 2) It does not work across file boundaries (if import a function from a different file, you don't have any information) 181 | 3) It doesn't work on member function calls (`foo.bar()` will not detect an error even if `bar` is an async function) 182 | -------------------------------------------------------------------------------- /tests/lib/rules/no-floating-promise.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests for no-floating-promise rule. 3 | * @author Sebastien Guillemot 4 | */ 5 | 6 | "use strict"; 7 | 8 | //------------------------------------------------------------------------------ 9 | // Requirements 10 | //------------------------------------------------------------------------------ 11 | 12 | const path = require("path"), 13 | rule = require("../../../lib/rules/no-floating-promise"), 14 | { RuleTester } = require('eslint'); 15 | 16 | //------------------------------------------------------------------------------ 17 | // Helpers 18 | //------------------------------------------------------------------------------ 19 | 20 | /** 21 | * Gets the specified parser. 22 | * 23 | * @param {string} name - The parser name to get. 24 | * @returns {object} The specificed parser 25 | */ 26 | function parser(name) { 27 | return require(`../../fixtures/parsers/no-floating-promise/${name}.js`); 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | // Tests 32 | //------------------------------------------------------------------------------ 33 | 34 | const ruleTester = new RuleTester({ languageOptions: { ecmaVersion: 8, sourceType: "module" } }); 35 | 36 | ruleTester.run("no-floating-promise", rule, { 37 | valid: [ 38 | { 39 | 40 | // awaiting a function identifier works 41 | code: "async function foo() {}; async function wrap() { await foo(); }", 42 | languageOptions: { ecmaVersion: 8 } 43 | }, 44 | { 45 | 46 | // if not awaited but used in an assignment, no error is reported 47 | code: "async function foo() {}; async function wrap() { const a = foo(); }", 48 | languageOptions: { ecmaVersion: 8 } 49 | }, 50 | { 51 | 52 | // if not awaited but returned, no error is reported 53 | code: "async function foo() {}; function bar() { return foo(); };", 54 | languageOptions: { ecmaVersion: 8 } 55 | }, 56 | { 57 | 58 | // awaiting a non-async function that returns a Promise works 59 | code: "function foo(): Promise { return Promise.resolve(); }; async function wrap() { await foo(); }", 60 | languageOptions: { 61 | ecmaVersion: 8, 62 | parser: parser("no-floating-promise-typed") 63 | } 64 | }, 65 | { 66 | 67 | // awaiting a FunctionExpression works 68 | code: "async function wrap() { await (async function () { return 5; })(); };", 69 | languageOptions: { ecmaVersion: 8 } 70 | }, 71 | { 72 | 73 | // awaiting an ArrowFunctionExpression works 74 | code: "async function wrap() { await (async () => 5)(); };", 75 | languageOptions: { ecmaVersion: 8 } 76 | }, 77 | { 78 | 79 | // doesn't break regular function calls 80 | code: "function foo() {}; foo();", 81 | languageOptions: { ecmaVersion: 8 } 82 | }, 83 | { 84 | 85 | /** 86 | * no Flow type definition that specified this function returns a promise 87 | * means unfortunately we won"t catch it 88 | */ 89 | code: "function foo() { return Promise.resolve(); }; async function wrap() { foo(); }", 90 | languageOptions: { ecmaVersion: 8 } 91 | }, 92 | { 93 | 94 | // doesn't crash when type "any" is used 95 | code: "function foo(): any { return Promise.resolve(); }; async function wrap() { foo(); }", 96 | languageOptions: { 97 | ecmaVersion: 8, 98 | parser: parser("floating-promise-any") 99 | } 100 | }, 101 | { 102 | 103 | // no error if then is used 104 | code: "async function foo() {}; async function wrap() { foo().then(() => {}); }", 105 | languageOptions: { ecmaVersion: 8 } 106 | }, 107 | { 108 | 109 | // This should fail but unfortunately it doesn't 110 | code: "class Foo { async bar() { } }; const foo = new Foo(); foo.bar();", 111 | }, 112 | { 113 | code: 'const foo = async ( lambda: void=>void ) { lambda(); }', 114 | languageOptions: { 115 | ecmaVersion: 8, 116 | parser: parser("no-floating-promise-argument") 117 | } 118 | } 119 | ], 120 | invalid: [ 121 | { 122 | 123 | // fails if missing an await on a regular function call 124 | code: "async function foo() {}; async function wrap() { foo(); }", 125 | output: "async function foo() {}; async function wrap() { await foo(); }", 126 | languageOptions: { ecmaVersion: 8 }, 127 | errors: [{ messageId: "foundFloating" }] 128 | }, 129 | { 130 | 131 | // fails if missing an await on a regular function call wrapped in something 132 | code: "async function foo() {}; async function wrap() { (foo)(); }", 133 | output: "async function foo() {}; async function wrap() { await (foo)(); }", 134 | languageOptions: { ecmaVersion: 8 }, 135 | errors: [{ messageId: "foundFloating" }] 136 | }, 137 | { 138 | 139 | // fails if you"re missing an await on a non-async function that returns a Promise 140 | code: "function foo(): Promise { return Promise.resolve(); }; async function wrap() { foo(); }", 141 | output: "function foo(): Promise { return Promise.resolve(); }; async function wrap() { await foo(); }", 142 | languageOptions: { 143 | ecmaVersion: 8, 144 | parser: parser("floating-promise-typed-identifier") 145 | }, 146 | errors: [{ messageId: "foundFloating" }] 147 | }, 148 | { 149 | 150 | // fails when missing an await on a FunctionExpression 151 | code: "async function wrap() { (async function () { return 5; })(); };", 152 | output: "async function wrap() { await (async function () { return 5; })(); };", 153 | languageOptions: { ecmaVersion: 8 }, 154 | errors: [{ messageId: "foundFloating" }] 155 | }, 156 | { 157 | 158 | // fails when missing an await on an ArrowFunctionExpression 159 | code: "async function wrap() { (async () => 5)(); };", 160 | output: "async function wrap() { await (async () => 5)(); };", 161 | languageOptions: { ecmaVersion: 8 }, 162 | errors: [{ messageId: "foundFloating" }] 163 | }, 164 | { 165 | 166 | // fails when missing an await on a non-async FunctionExpression that returns a Promise 167 | code: "async function wrap() { (function (): Promise { return Promise.resolve(); })(); };", 168 | output: "async function wrap() { await (function (): Promise { return Promise.resolve(); })(); };", 169 | languageOptions: { 170 | ecmaVersion: 8, 171 | parser: parser("floating-promise-typed-expression") 172 | }, 173 | errors: [{ messageId: "foundFloating" }] 174 | }, 175 | { 176 | 177 | // calling a lambda function argument 178 | code: 'class Foo { foo = async ( lambda: (void=>Promise) ) => { lambda(); }}', 179 | output: 'class Foo { foo = async ( lambda: (void=>Promise) ) => { await lambda(); }}', 180 | languageOptions: { 181 | ecmaVersion: 8, 182 | parser: parser("floating-promise-argument") 183 | }, 184 | errors: [{ messageId: "foundFloating" }] 185 | }, 186 | ] 187 | }); 188 | -------------------------------------------------------------------------------- /tests/fixtures/parsers/no-floating-promise/no-floating-promise-argument.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Source code: 3 | * function class Foo { foo = async ( lambda: (void=>void) ) => { lambda(); }} 4 | */ 5 | 6 | exports.parse = () => ({ 7 | type: 'Program', 8 | start: 0, 9 | end: 66, 10 | loc: { 11 | start: { 12 | line: 1, 13 | column: 0 14 | }, 15 | end: { 16 | line: 1, 17 | column: 66 18 | } 19 | }, 20 | range: [0, 66], 21 | comments: [], 22 | tokens: [{ 23 | type: 'Keyword', 24 | value: 'class', 25 | start: 0, 26 | end: 5, 27 | loc: { 28 | start: { 29 | line: 1, 30 | column: 0 31 | }, 32 | end: { 33 | line: 1, 34 | column: 5 35 | } 36 | }, 37 | range: [0, 5] 38 | }, 39 | { 40 | type: 'Identifier', 41 | value: 'Foo', 42 | start: 6, 43 | end: 9, 44 | loc: { 45 | start: { 46 | line: 1, 47 | column: 6 48 | }, 49 | end: { 50 | line: 1, 51 | column: 9 52 | } 53 | }, 54 | range: [6, 9] 55 | }, 56 | { 57 | type: 'Punctuator', 58 | value: '{', 59 | start: 10, 60 | end: 11, 61 | loc: { 62 | start: { 63 | line: 1, 64 | column: 10 65 | }, 66 | end: { 67 | line: 1, 68 | column: 11 69 | } 70 | }, 71 | range: [10, 11] 72 | }, 73 | { 74 | type: 'Identifier', 75 | value: 'foo', 76 | start: 12, 77 | end: 15, 78 | loc: { 79 | start: { 80 | line: 1, 81 | column: 12 82 | }, 83 | end: { 84 | line: 1, 85 | column: 15 86 | } 87 | }, 88 | range: [12, 15] 89 | }, 90 | { 91 | type: 'Punctuator', 92 | value: '=', 93 | start: 16, 94 | end: 17, 95 | loc: { 96 | start: { 97 | line: 1, 98 | column: 16 99 | }, 100 | end: { 101 | line: 1, 102 | column: 17 103 | } 104 | }, 105 | range: [16, 17] 106 | }, 107 | { 108 | type: 'Identifier', 109 | value: 'async', 110 | start: 18, 111 | end: 23, 112 | loc: { 113 | start: { 114 | line: 1, 115 | column: 18 116 | }, 117 | end: { 118 | line: 1, 119 | column: 23 120 | } 121 | }, 122 | range: [18, 23] 123 | }, 124 | { 125 | type: 'Punctuator', 126 | value: '(', 127 | start: 24, 128 | end: 25, 129 | loc: { 130 | start: { 131 | line: 1, 132 | column: 24 133 | }, 134 | end: { 135 | line: 1, 136 | column: 25 137 | } 138 | }, 139 | range: [24, 25] 140 | }, 141 | { 142 | type: 'Identifier', 143 | value: 'lambda', 144 | start: 26, 145 | end: 32, 146 | loc: { 147 | start: { 148 | line: 1, 149 | column: 26 150 | }, 151 | end: { 152 | line: 1, 153 | column: 32 154 | } 155 | }, 156 | range: [26, 32] 157 | }, 158 | { 159 | type: 'Punctuator', 160 | value: ':', 161 | start: 32, 162 | end: 33, 163 | loc: { 164 | start: { 165 | line: 1, 166 | column: 32 167 | }, 168 | end: { 169 | line: 1, 170 | column: 33 171 | } 172 | }, 173 | range: [32, 33] 174 | }, 175 | { 176 | type: 'Punctuator', 177 | value: '(', 178 | start: 34, 179 | end: 35, 180 | loc: { 181 | start: { 182 | line: 1, 183 | column: 34 184 | }, 185 | end: { 186 | line: 1, 187 | column: 35 188 | } 189 | }, 190 | range: [34, 35] 191 | }, 192 | { 193 | type: 'Keyword', 194 | value: 'void', 195 | start: 35, 196 | end: 39, 197 | loc: { 198 | start: { 199 | line: 1, 200 | column: 35 201 | }, 202 | end: { 203 | line: 1, 204 | column: 39 205 | } 206 | }, 207 | range: [35, 39] 208 | }, 209 | { 210 | type: 'Punctuator', 211 | value: '=>', 212 | start: 39, 213 | end: 41, 214 | loc: { 215 | start: { 216 | line: 1, 217 | column: 39 218 | }, 219 | end: { 220 | line: 1, 221 | column: 41 222 | } 223 | }, 224 | range: [39, 41] 225 | }, 226 | { 227 | type: 'Keyword', 228 | value: 'void', 229 | start: 41, 230 | end: 45, 231 | loc: { 232 | start: { 233 | line: 1, 234 | column: 41 235 | }, 236 | end: { 237 | line: 1, 238 | column: 45 239 | } 240 | }, 241 | range: [41, 45] 242 | }, 243 | { 244 | type: 'Punctuator', 245 | value: ')', 246 | start: 45, 247 | end: 46, 248 | loc: { 249 | start: { 250 | line: 1, 251 | column: 45 252 | }, 253 | end: { 254 | line: 1, 255 | column: 46 256 | } 257 | }, 258 | range: [45, 46] 259 | }, 260 | { 261 | type: 'Punctuator', 262 | value: ')', 263 | start: 47, 264 | end: 48, 265 | loc: { 266 | start: { 267 | line: 1, 268 | column: 47 269 | }, 270 | end: { 271 | line: 1, 272 | column: 48 273 | } 274 | }, 275 | range: [47, 48] 276 | }, 277 | { 278 | type: 'Punctuator', 279 | value: '=>', 280 | start: 49, 281 | end: 51, 282 | loc: { 283 | start: { 284 | line: 1, 285 | column: 49 286 | }, 287 | end: { 288 | line: 1, 289 | column: 51 290 | } 291 | }, 292 | range: [49, 51] 293 | }, 294 | { 295 | type: 'Punctuator', 296 | value: '{', 297 | start: 52, 298 | end: 53, 299 | loc: { 300 | start: { 301 | line: 1, 302 | column: 52 303 | }, 304 | end: { 305 | line: 1, 306 | column: 53 307 | } 308 | }, 309 | range: [52, 53] 310 | }, 311 | { 312 | type: 'Identifier', 313 | value: 'lambda', 314 | start: 54, 315 | end: 60, 316 | loc: { 317 | start: { 318 | line: 1, 319 | column: 54 320 | }, 321 | end: { 322 | line: 1, 323 | column: 60 324 | } 325 | }, 326 | range: [54, 60] 327 | }, 328 | { 329 | type: 'Punctuator', 330 | value: '(', 331 | start: 60, 332 | end: 61, 333 | loc: { 334 | start: { 335 | line: 1, 336 | column: 60 337 | }, 338 | end: { 339 | line: 1, 340 | column: 61 341 | } 342 | }, 343 | range: [60, 61] 344 | }, 345 | { 346 | type: 'Punctuator', 347 | value: ')', 348 | start: 61, 349 | end: 62, 350 | loc: { 351 | start: { 352 | line: 1, 353 | column: 61 354 | }, 355 | end: { 356 | line: 1, 357 | column: 62 358 | } 359 | }, 360 | range: [61, 62] 361 | }, 362 | { 363 | type: 'Punctuator', 364 | value: ';', 365 | start: 62, 366 | end: 63, 367 | loc: { 368 | start: { 369 | line: 1, 370 | column: 62 371 | }, 372 | end: { 373 | line: 1, 374 | column: 63 375 | } 376 | }, 377 | range: [62, 63] 378 | }, 379 | { 380 | type: 'Punctuator', 381 | value: '}', 382 | start: 64, 383 | end: 65, 384 | loc: { 385 | start: { 386 | line: 1, 387 | column: 64 388 | }, 389 | end: { 390 | line: 1, 391 | column: 65 392 | } 393 | }, 394 | range: [64, 65] 395 | }, 396 | { 397 | type: 'Punctuator', 398 | value: '}', 399 | start: 65, 400 | end: 66, 401 | loc: { 402 | start: { 403 | line: 1, 404 | column: 65 405 | }, 406 | end: { 407 | line: 1, 408 | column: 66 409 | } 410 | }, 411 | range: [65, 66] 412 | } 413 | ], 414 | sourceType: 'module', 415 | directives: undefined, 416 | body: [{ 417 | type: 'ClassDeclaration', 418 | start: 0, 419 | end: 66, 420 | loc: { 421 | start: { 422 | line: 1, 423 | column: 0 424 | }, 425 | end: { 426 | line: 1, 427 | column: 66 428 | } 429 | }, 430 | range: [0, 66], 431 | id: { 432 | type: 'Identifier', 433 | start: 6, 434 | end: 9, 435 | loc: { 436 | start: { 437 | line: 1, 438 | column: 6 439 | }, 440 | end: { 441 | line: 1, 442 | column: 9 443 | }, 444 | identifierName: 'Foo' 445 | }, 446 | range: [6, 9], 447 | name: 'Foo', 448 | _babelType: 'Identifier', 449 | }, 450 | superClass: null, 451 | body: { 452 | type: 'ClassBody', 453 | start: 10, 454 | end: 66, 455 | loc: { 456 | start: { 457 | line: 1, 458 | column: 10 459 | }, 460 | end: { 461 | line: 1, 462 | column: 66 463 | } 464 | }, 465 | range: [10, 66], 466 | body: [{ 467 | type: 'ClassProperty', 468 | start: 12, 469 | end: 65, 470 | loc: { 471 | start: { 472 | line: 1, 473 | column: 12 474 | }, 475 | end: { 476 | line: 1, 477 | column: 65 478 | } 479 | }, 480 | range: [12, 65], 481 | static: false, 482 | key: { 483 | type: 'Identifier', 484 | start: 12, 485 | end: 15, 486 | loc: { 487 | start: { 488 | line: 1, 489 | column: 12 490 | }, 491 | end: { 492 | line: 1, 493 | column: 15 494 | }, 495 | identifierName: 'foo' 496 | }, 497 | range: [12, 15], 498 | name: 'foo', 499 | _babelType: 'Identifier', 500 | }, 501 | computed: false, 502 | variance: null, 503 | value: { 504 | type: 'ArrowFunctionExpression', 505 | start: 18, 506 | end: 65, 507 | loc: { 508 | start: { 509 | line: 1, 510 | column: 18 511 | }, 512 | end: { 513 | line: 1, 514 | column: 65 515 | } 516 | }, 517 | range: [18, 65], 518 | id: null, 519 | generator: false, 520 | async: true, 521 | expression: false, 522 | params: [{ 523 | type: 'Identifier', 524 | start: 26, 525 | end: 46, 526 | loc: { 527 | start: { 528 | line: 1, 529 | column: 26 530 | }, 531 | end: { 532 | line: 1, 533 | column: 46 534 | }, 535 | identifierName: 'lambda' 536 | }, 537 | range: [26, 46], 538 | name: 'lambda', 539 | typeAnnotation: { 540 | type: 'TypeAnnotation', 541 | start: 32, 542 | end: 46, 543 | loc: { 544 | start: { 545 | line: 1, 546 | column: 32 547 | }, 548 | end: { 549 | line: 1, 550 | column: 46 551 | } 552 | }, 553 | range: [32, 46], 554 | typeAnnotation: { 555 | type: 'FunctionTypeAnnotation', 556 | start: 35, 557 | end: 45, 558 | loc: { 559 | start: { 560 | line: 1, 561 | column: 35 562 | }, 563 | end: { 564 | line: 1, 565 | column: 45 566 | } 567 | }, 568 | range: [35, 45], 569 | params: [{ 570 | type: 'FunctionTypeParam', 571 | start: 35, 572 | end: 41, 573 | loc: { 574 | start: { 575 | line: 1, 576 | column: 35 577 | }, 578 | end: { 579 | line: 1, 580 | column: 41 581 | } 582 | }, 583 | range: [35, 41], 584 | optional: false, 585 | typeAnnotation: { 586 | type: 'VoidTypeAnnotation', 587 | start: 35, 588 | end: 39, 589 | loc: { 590 | start: { 591 | line: 1, 592 | column: 35 593 | }, 594 | end: { 595 | line: 1, 596 | column: 39 597 | } 598 | }, 599 | range: [35, 39], 600 | _babelType: 'VoidTypeAnnotation', 601 | }, 602 | _babelType: 'FunctionTypeParam', 603 | }], 604 | rest: null, 605 | returnType: { 606 | type: 'VoidTypeAnnotation', 607 | start: 41, 608 | end: 45, 609 | loc: { 610 | start: { 611 | line: 1, 612 | column: 41 613 | }, 614 | end: { 615 | line: 1, 616 | column: 45 617 | } 618 | }, 619 | range: [41, 45], 620 | _babelType: 'VoidTypeAnnotation', 621 | }, 622 | typeParameters: null, 623 | _babelType: 'FunctionTypeAnnotation', 624 | }, 625 | _babelType: 'TypeAnnotation', 626 | }, 627 | _babelType: 'Identifier', 628 | }], 629 | body: { 630 | type: 'BlockStatement', 631 | start: 52, 632 | end: 65, 633 | loc: { 634 | start: { 635 | line: 1, 636 | column: 52 637 | }, 638 | end: { 639 | line: 1, 640 | column: 65 641 | } 642 | }, 643 | range: [52, 65], 644 | body: [{ 645 | type: 'ExpressionStatement', 646 | start: 54, 647 | end: 63, 648 | loc: { 649 | start: { 650 | line: 1, 651 | column: 54 652 | }, 653 | end: { 654 | line: 1, 655 | column: 63 656 | } 657 | }, 658 | range: [54, 63], 659 | expression: { 660 | type: 'CallExpression', 661 | start: 54, 662 | end: 62, 663 | loc: { 664 | start: { 665 | line: 1, 666 | column: 54 667 | }, 668 | end: { 669 | line: 1, 670 | column: 62 671 | } 672 | }, 673 | range: [54, 62], 674 | callee: { 675 | type: 'Identifier', 676 | start: 54, 677 | end: 60, 678 | loc: { 679 | start: { 680 | line: 1, 681 | column: 54 682 | }, 683 | end: { 684 | line: 1, 685 | column: 60 686 | }, 687 | identifierName: 'lambda' 688 | }, 689 | range: [54, 60], 690 | name: 'lambda', 691 | _babelType: 'Identifier', 692 | }, 693 | arguments: [], 694 | _babelType: 'CallExpression', 695 | }, 696 | _babelType: 'ExpressionStatement', 697 | }], 698 | _babelType: 'BlockStatement', 699 | }, 700 | _babelType: 'ArrowFunctionExpression', 701 | }, 702 | _babelType: 'ClassProperty', 703 | }], 704 | _babelType: 'ClassBody', 705 | }, 706 | _babelType: 'ClassDeclaration', 707 | }], 708 | }) -------------------------------------------------------------------------------- /tests/fixtures/parsers/no-floating-promise/floating-promise-any.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Source code: 3 | * function foo(): any { return Promise.resolve(); }; async function wrap() { foo(); } 4 | */ 5 | 6 | exports.parse = () => ({ 7 | type: 'Program', 8 | start: 0, 9 | end: 83, 10 | loc: { 11 | start: { 12 | line: 1, 13 | column: 0 14 | }, 15 | end: { 16 | line: 1, 17 | column: 83 18 | } 19 | }, 20 | range: [0, 83], 21 | comments: [], 22 | tokens: [{ 23 | type: 'Keyword', 24 | value: 'function', 25 | start: 0, 26 | end: 8, 27 | loc: { 28 | start: { 29 | line: 1, 30 | column: 0 31 | }, 32 | end: { 33 | line: 1, 34 | column: 8 35 | } 36 | }, 37 | range: [0, 8] 38 | }, 39 | { 40 | type: 'Identifier', 41 | value: 'foo', 42 | start: 9, 43 | end: 12, 44 | loc: { 45 | start: { 46 | line: 1, 47 | column: 9 48 | }, 49 | end: { 50 | line: 1, 51 | column: 12 52 | } 53 | }, 54 | range: [9, 12] 55 | }, 56 | { 57 | type: 'Punctuator', 58 | value: '(', 59 | start: 12, 60 | end: 13, 61 | loc: { 62 | start: { 63 | line: 1, 64 | column: 12 65 | }, 66 | end: { 67 | line: 1, 68 | column: 13 69 | } 70 | }, 71 | range: [12, 13] 72 | }, 73 | { 74 | type: 'Punctuator', 75 | value: ')', 76 | start: 13, 77 | end: 14, 78 | loc: { 79 | start: { 80 | line: 1, 81 | column: 13 82 | }, 83 | end: { 84 | line: 1, 85 | column: 14 86 | } 87 | }, 88 | range: [13, 14] 89 | }, 90 | { 91 | type: 'Punctuator', 92 | value: ':', 93 | start: 14, 94 | end: 15, 95 | loc: { 96 | start: { 97 | line: 1, 98 | column: 14 99 | }, 100 | end: { 101 | line: 1, 102 | column: 15 103 | } 104 | }, 105 | range: [14, 15] 106 | }, 107 | { 108 | type: 'Identifier', 109 | value: 'any', 110 | start: 16, 111 | end: 19, 112 | loc: { 113 | start: { 114 | line: 1, 115 | column: 16 116 | }, 117 | end: { 118 | line: 1, 119 | column: 19 120 | } 121 | }, 122 | range: [16, 19] 123 | }, 124 | { 125 | type: 'Punctuator', 126 | value: '{', 127 | start: 20, 128 | end: 21, 129 | loc: { 130 | start: { 131 | line: 1, 132 | column: 20 133 | }, 134 | end: { 135 | line: 1, 136 | column: 21 137 | } 138 | }, 139 | range: [20, 21] 140 | }, 141 | { 142 | type: 'Keyword', 143 | value: 'return', 144 | start: 22, 145 | end: 28, 146 | loc: { 147 | start: { 148 | line: 1, 149 | column: 22 150 | }, 151 | end: { 152 | line: 1, 153 | column: 28 154 | } 155 | }, 156 | range: [22, 28] 157 | }, 158 | { 159 | type: 'Identifier', 160 | value: 'Promise', 161 | start: 29, 162 | end: 36, 163 | loc: { 164 | start: { 165 | line: 1, 166 | column: 29 167 | }, 168 | end: { 169 | line: 1, 170 | column: 36 171 | } 172 | }, 173 | range: [29, 36] 174 | }, 175 | { 176 | type: 'Punctuator', 177 | value: '.', 178 | start: 36, 179 | end: 37, 180 | loc: { 181 | start: { 182 | line: 1, 183 | column: 36 184 | }, 185 | end: { 186 | line: 1, 187 | column: 37 188 | } 189 | }, 190 | range: [36, 37] 191 | }, 192 | { 193 | type: 'Identifier', 194 | value: 'resolve', 195 | start: 37, 196 | end: 44, 197 | loc: { 198 | start: { 199 | line: 1, 200 | column: 37 201 | }, 202 | end: { 203 | line: 1, 204 | column: 44 205 | } 206 | }, 207 | range: [37, 44] 208 | }, 209 | { 210 | type: 'Punctuator', 211 | value: '(', 212 | start: 44, 213 | end: 45, 214 | loc: { 215 | start: { 216 | line: 1, 217 | column: 44 218 | }, 219 | end: { 220 | line: 1, 221 | column: 45 222 | } 223 | }, 224 | range: [44, 45] 225 | }, 226 | { 227 | type: 'Punctuator', 228 | value: ')', 229 | start: 45, 230 | end: 46, 231 | loc: { 232 | start: { 233 | line: 1, 234 | column: 45 235 | }, 236 | end: { 237 | line: 1, 238 | column: 46 239 | } 240 | }, 241 | range: [45, 46] 242 | }, 243 | { 244 | type: 'Punctuator', 245 | value: ';', 246 | start: 46, 247 | end: 47, 248 | loc: { 249 | start: { 250 | line: 1, 251 | column: 46 252 | }, 253 | end: { 254 | line: 1, 255 | column: 47 256 | } 257 | }, 258 | range: [46, 47] 259 | }, 260 | { 261 | type: 'Punctuator', 262 | value: '}', 263 | start: 48, 264 | end: 49, 265 | loc: { 266 | start: { 267 | line: 1, 268 | column: 48 269 | }, 270 | end: { 271 | line: 1, 272 | column: 49 273 | } 274 | }, 275 | range: [48, 49] 276 | }, 277 | { 278 | type: 'Punctuator', 279 | value: ';', 280 | start: 49, 281 | end: 50, 282 | loc: { 283 | start: { 284 | line: 1, 285 | column: 49 286 | }, 287 | end: { 288 | line: 1, 289 | column: 50 290 | } 291 | }, 292 | range: [49, 50] 293 | }, 294 | { 295 | type: 'Identifier', 296 | value: 'async', 297 | start: 51, 298 | end: 56, 299 | loc: { 300 | start: { 301 | line: 1, 302 | column: 51 303 | }, 304 | end: { 305 | line: 1, 306 | column: 56 307 | } 308 | }, 309 | range: [51, 56] 310 | }, 311 | { 312 | type: 'Keyword', 313 | value: 'function', 314 | start: 57, 315 | end: 65, 316 | loc: { 317 | start: { 318 | line: 1, 319 | column: 57 320 | }, 321 | end: { 322 | line: 1, 323 | column: 65 324 | } 325 | }, 326 | range: [57, 65] 327 | }, 328 | { 329 | type: 'Identifier', 330 | value: 'wrap', 331 | start: 66, 332 | end: 70, 333 | loc: { 334 | start: { 335 | line: 1, 336 | column: 66 337 | }, 338 | end: { 339 | line: 1, 340 | column: 70 341 | } 342 | }, 343 | range: [66, 70] 344 | }, 345 | { 346 | type: 'Punctuator', 347 | value: '(', 348 | start: 70, 349 | end: 71, 350 | loc: { 351 | start: { 352 | line: 1, 353 | column: 70 354 | }, 355 | end: { 356 | line: 1, 357 | column: 71 358 | } 359 | }, 360 | range: [70, 71] 361 | }, 362 | { 363 | type: 'Punctuator', 364 | value: ')', 365 | start: 71, 366 | end: 72, 367 | loc: { 368 | start: { 369 | line: 1, 370 | column: 71 371 | }, 372 | end: { 373 | line: 1, 374 | column: 72 375 | } 376 | }, 377 | range: [71, 72] 378 | }, 379 | { 380 | type: 'Punctuator', 381 | value: '{', 382 | start: 73, 383 | end: 74, 384 | loc: { 385 | start: { 386 | line: 1, 387 | column: 73 388 | }, 389 | end: { 390 | line: 1, 391 | column: 74 392 | } 393 | }, 394 | range: [73, 74] 395 | }, 396 | { 397 | type: 'Identifier', 398 | value: 'foo', 399 | start: 75, 400 | end: 78, 401 | loc: { 402 | start: { 403 | line: 1, 404 | column: 75 405 | }, 406 | end: { 407 | line: 1, 408 | column: 78 409 | } 410 | }, 411 | range: [75, 78] 412 | }, 413 | { 414 | type: 'Punctuator', 415 | value: '(', 416 | start: 78, 417 | end: 79, 418 | loc: { 419 | start: { 420 | line: 1, 421 | column: 78 422 | }, 423 | end: { 424 | line: 1, 425 | column: 79 426 | } 427 | }, 428 | range: [78, 79] 429 | }, 430 | { 431 | type: 'Punctuator', 432 | value: ')', 433 | start: 79, 434 | end: 80, 435 | loc: { 436 | start: { 437 | line: 1, 438 | column: 79 439 | }, 440 | end: { 441 | line: 1, 442 | column: 80 443 | } 444 | }, 445 | range: [79, 80] 446 | }, 447 | { 448 | type: 'Punctuator', 449 | value: ';', 450 | start: 80, 451 | end: 81, 452 | loc: { 453 | start: { 454 | line: 1, 455 | column: 80 456 | }, 457 | end: { 458 | line: 1, 459 | column: 81 460 | } 461 | }, 462 | range: [80, 81] 463 | }, 464 | { 465 | type: 'Punctuator', 466 | value: '}', 467 | start: 82, 468 | end: 83, 469 | loc: { 470 | start: { 471 | line: 1, 472 | column: 82 473 | }, 474 | end: { 475 | line: 1, 476 | column: 83 477 | } 478 | }, 479 | range: [82, 83] 480 | } 481 | ], 482 | sourceType: 'module', 483 | directives: undefined, 484 | body: [{ 485 | type: 'FunctionDeclaration', 486 | start: 0, 487 | end: 49, 488 | loc: { 489 | start: { 490 | line: 1, 491 | column: 0 492 | }, 493 | end: { 494 | line: 1, 495 | column: 49 496 | } 497 | }, 498 | range: [0, 49], 499 | id: { 500 | type: 'Identifier', 501 | start: 9, 502 | end: 12, 503 | loc: { 504 | start: { 505 | line: 1, 506 | column: 9 507 | }, 508 | end: { 509 | line: 1, 510 | column: 12 511 | }, 512 | identifierName: 'foo' 513 | }, 514 | range: [9, 12], 515 | name: 'foo', 516 | _babelType: 'Identifier', 517 | }, 518 | generator: false, 519 | async: false, 520 | expression: false, 521 | params: [], 522 | predicate: null, 523 | returnType: { 524 | type: 'TypeAnnotation', 525 | start: 14, 526 | end: 19, 527 | loc: { 528 | start: { 529 | line: 1, 530 | column: 14 531 | }, 532 | end: { 533 | line: 1, 534 | column: 19 535 | } 536 | }, 537 | range: [14, 19], 538 | typeAnnotation: { 539 | type: 'AnyTypeAnnotation', 540 | start: 16, 541 | end: 19, 542 | loc: { 543 | start: { 544 | line: 1, 545 | column: 16 546 | }, 547 | end: { 548 | line: 1, 549 | column: 19 550 | } 551 | }, 552 | range: [16, 19], 553 | _babelType: 'AnyTypeAnnotation', 554 | }, 555 | _babelType: 'TypeAnnotation', 556 | }, 557 | body: { 558 | type: 'BlockStatement', 559 | start: 20, 560 | end: 49, 561 | loc: { 562 | start: { 563 | line: 1, 564 | column: 20 565 | }, 566 | end: { 567 | line: 1, 568 | column: 49 569 | } 570 | }, 571 | range: [20, 49], 572 | body: [{ 573 | type: 'ReturnStatement', 574 | start: 22, 575 | end: 47, 576 | loc: { 577 | start: { 578 | line: 1, 579 | column: 22 580 | }, 581 | end: { 582 | line: 1, 583 | column: 47 584 | } 585 | }, 586 | range: [22, 47], 587 | argument: { 588 | type: 'CallExpression', 589 | start: 29, 590 | end: 46, 591 | loc: { 592 | start: { 593 | line: 1, 594 | column: 29 595 | }, 596 | end: { 597 | line: 1, 598 | column: 46 599 | } 600 | }, 601 | range: [29, 46], 602 | callee: { 603 | type: 'MemberExpression', 604 | start: 29, 605 | end: 44, 606 | loc: { 607 | start: { 608 | line: 1, 609 | column: 29 610 | }, 611 | end: { 612 | line: 1, 613 | column: 44 614 | } 615 | }, 616 | range: [29, 44], 617 | object: { 618 | type: 'Identifier', 619 | start: 29, 620 | end: 36, 621 | loc: { 622 | start: { 623 | line: 1, 624 | column: 29 625 | }, 626 | end: { 627 | line: 1, 628 | column: 36 629 | }, 630 | identifierName: 'Promise' 631 | }, 632 | range: [29, 36], 633 | name: 'Promise', 634 | _babelType: 'Identifier', 635 | }, 636 | property: { 637 | type: 'Identifier', 638 | start: 37, 639 | end: 44, 640 | loc: { 641 | start: { 642 | line: 1, 643 | column: 37 644 | }, 645 | end: { 646 | line: 1, 647 | column: 44 648 | }, 649 | identifierName: 'resolve' 650 | }, 651 | range: [37, 44], 652 | name: 'resolve', 653 | _babelType: 'Identifier', 654 | }, 655 | computed: false, 656 | _babelType: 'MemberExpression', 657 | }, 658 | arguments: [], 659 | _babelType: 'CallExpression', 660 | }, 661 | _babelType: 'ReturnStatement', 662 | }], 663 | _babelType: 'BlockStatement', 664 | }, 665 | _babelType: 'FunctionDeclaration', 666 | }, 667 | { 668 | type: 'EmptyStatement', 669 | start: 49, 670 | end: 50, 671 | loc: { 672 | start: { 673 | line: 1, 674 | column: 49 675 | }, 676 | end: { 677 | line: 1, 678 | column: 50 679 | } 680 | }, 681 | range: [49, 50], 682 | _babelType: 'EmptyStatement', 683 | }, 684 | { 685 | type: 'FunctionDeclaration', 686 | start: 51, 687 | end: 83, 688 | loc: { 689 | start: { 690 | line: 1, 691 | column: 51 692 | }, 693 | end: { 694 | line: 1, 695 | column: 83 696 | } 697 | }, 698 | range: [51, 83], 699 | id: { 700 | type: 'Identifier', 701 | start: 66, 702 | end: 70, 703 | loc: { 704 | start: { 705 | line: 1, 706 | column: 66 707 | }, 708 | end: { 709 | line: 1, 710 | column: 70 711 | }, 712 | identifierName: 'wrap' 713 | }, 714 | range: [66, 70], 715 | name: 'wrap', 716 | _babelType: 'Identifier', 717 | }, 718 | generator: false, 719 | async: true, 720 | expression: false, 721 | params: [], 722 | body: { 723 | type: 'BlockStatement', 724 | start: 73, 725 | end: 83, 726 | loc: { 727 | start: { 728 | line: 1, 729 | column: 73 730 | }, 731 | end: { 732 | line: 1, 733 | column: 83 734 | } 735 | }, 736 | range: [73, 83], 737 | body: [{ 738 | type: 'ExpressionStatement', 739 | start: 75, 740 | end: 81, 741 | loc: { 742 | start: { 743 | line: 1, 744 | column: 75 745 | }, 746 | end: { 747 | line: 1, 748 | column: 81 749 | } 750 | }, 751 | range: [75, 81], 752 | expression: { 753 | type: 'CallExpression', 754 | start: 75, 755 | end: 80, 756 | loc: { 757 | start: { 758 | line: 1, 759 | column: 75 760 | }, 761 | end: { 762 | line: 1, 763 | column: 80 764 | } 765 | }, 766 | range: [75, 80], 767 | callee: { 768 | type: 'Identifier', 769 | start: 75, 770 | end: 78, 771 | loc: { 772 | start: { 773 | line: 1, 774 | column: 75 775 | }, 776 | end: { 777 | line: 1, 778 | column: 78 779 | }, 780 | identifierName: 'foo' 781 | }, 782 | range: [75, 78], 783 | name: 'foo', 784 | _babelType: 'Identifier', 785 | }, 786 | arguments: [], 787 | _babelType: 'CallExpression', 788 | }, 789 | _babelType: 'ExpressionStatement', 790 | }], 791 | _babelType: 'BlockStatement', 792 | }, 793 | _babelType: 'FunctionDeclaration', 794 | } 795 | ], 796 | }); 797 | -------------------------------------------------------------------------------- /tests/fixtures/parsers/no-floating-promise/floating-promise-argument.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Source code: 3 | * 4 | */ 5 | 6 | exports.parse = () => ({ 7 | type: 'Program', 8 | start: 0, 9 | end: 75, 10 | loc: { 11 | start: { 12 | line: 1, 13 | column: 0 14 | }, 15 | end: { 16 | line: 1, 17 | column: 75 18 | } 19 | }, 20 | range: [0, 75], 21 | comments: [], 22 | tokens: [{ 23 | type: 'Keyword', 24 | value: 'class', 25 | start: 0, 26 | end: 5, 27 | loc: { 28 | start: { 29 | line: 1, 30 | column: 0 31 | }, 32 | end: { 33 | line: 1, 34 | column: 5 35 | } 36 | }, 37 | range: [0, 5] 38 | }, 39 | { 40 | type: 'Identifier', 41 | value: 'Foo', 42 | start: 6, 43 | end: 9, 44 | loc: { 45 | start: { 46 | line: 1, 47 | column: 6 48 | }, 49 | end: { 50 | line: 1, 51 | column: 9 52 | } 53 | }, 54 | range: [6, 9] 55 | }, 56 | { 57 | type: 'Punctuator', 58 | value: '{', 59 | start: 10, 60 | end: 11, 61 | loc: { 62 | start: { 63 | line: 1, 64 | column: 10 65 | }, 66 | end: { 67 | line: 1, 68 | column: 11 69 | } 70 | }, 71 | range: [10, 11] 72 | }, 73 | { 74 | type: 'Identifier', 75 | value: 'foo', 76 | start: 12, 77 | end: 15, 78 | loc: { 79 | start: { 80 | line: 1, 81 | column: 12 82 | }, 83 | end: { 84 | line: 1, 85 | column: 15 86 | } 87 | }, 88 | range: [12, 15] 89 | }, 90 | { 91 | type: 'Punctuator', 92 | value: '=', 93 | start: 16, 94 | end: 17, 95 | loc: { 96 | start: { 97 | line: 1, 98 | column: 16 99 | }, 100 | end: { 101 | line: 1, 102 | column: 17 103 | } 104 | }, 105 | range: [16, 17] 106 | }, 107 | { 108 | type: 'Identifier', 109 | value: 'async', 110 | start: 18, 111 | end: 23, 112 | loc: { 113 | start: { 114 | line: 1, 115 | column: 18 116 | }, 117 | end: { 118 | line: 1, 119 | column: 23 120 | } 121 | }, 122 | range: [18, 23] 123 | }, 124 | { 125 | type: 'Punctuator', 126 | value: '(', 127 | start: 24, 128 | end: 25, 129 | loc: { 130 | start: { 131 | line: 1, 132 | column: 24 133 | }, 134 | end: { 135 | line: 1, 136 | column: 25 137 | } 138 | }, 139 | range: [24, 25] 140 | }, 141 | { 142 | type: 'Identifier', 143 | value: 'lambda', 144 | start: 26, 145 | end: 32, 146 | loc: { 147 | start: { 148 | line: 1, 149 | column: 26 150 | }, 151 | end: { 152 | line: 1, 153 | column: 32 154 | } 155 | }, 156 | range: [26, 32] 157 | }, 158 | { 159 | type: 'Punctuator', 160 | value: ':', 161 | start: 32, 162 | end: 33, 163 | loc: { 164 | start: { 165 | line: 1, 166 | column: 32 167 | }, 168 | end: { 169 | line: 1, 170 | column: 33 171 | } 172 | }, 173 | range: [32, 33] 174 | }, 175 | { 176 | type: 'Punctuator', 177 | value: '(', 178 | start: 34, 179 | end: 35, 180 | loc: { 181 | start: { 182 | line: 1, 183 | column: 34 184 | }, 185 | end: { 186 | line: 1, 187 | column: 35 188 | } 189 | }, 190 | range: [34, 35] 191 | }, 192 | { 193 | type: 'Keyword', 194 | value: 'void', 195 | start: 35, 196 | end: 39, 197 | loc: { 198 | start: { 199 | line: 1, 200 | column: 35 201 | }, 202 | end: { 203 | line: 1, 204 | column: 39 205 | } 206 | }, 207 | range: [35, 39] 208 | }, 209 | { 210 | type: 'Punctuator', 211 | value: '=>', 212 | start: 39, 213 | end: 41, 214 | loc: { 215 | start: { 216 | line: 1, 217 | column: 39 218 | }, 219 | end: { 220 | line: 1, 221 | column: 41 222 | } 223 | }, 224 | range: [39, 41] 225 | }, 226 | { 227 | type: 'Identifier', 228 | value: 'Promise', 229 | start: 41, 230 | end: 48, 231 | loc: { 232 | start: { 233 | line: 1, 234 | column: 41 235 | }, 236 | end: { 237 | line: 1, 238 | column: 48 239 | } 240 | }, 241 | range: [41, 48] 242 | }, 243 | { 244 | type: 'Punctuator', 245 | value: '<', 246 | start: 48, 247 | end: 49, 248 | loc: { 249 | start: { 250 | line: 1, 251 | column: 48 252 | }, 253 | end: { 254 | line: 1, 255 | column: 49 256 | } 257 | }, 258 | range: [48, 49] 259 | }, 260 | { 261 | type: 'Keyword', 262 | value: 'void', 263 | start: 49, 264 | end: 53, 265 | loc: { 266 | start: { 267 | line: 1, 268 | column: 49 269 | }, 270 | end: { 271 | line: 1, 272 | column: 53 273 | } 274 | }, 275 | range: [49, 53] 276 | }, 277 | { 278 | type: 'Punctuator', 279 | value: '>', 280 | start: 53, 281 | end: 54, 282 | loc: { 283 | start: { 284 | line: 1, 285 | column: 53 286 | }, 287 | end: { 288 | line: 1, 289 | column: 54 290 | } 291 | }, 292 | range: [53, 54] 293 | }, 294 | { 295 | type: 'Punctuator', 296 | value: ')', 297 | start: 54, 298 | end: 55, 299 | loc: { 300 | start: { 301 | line: 1, 302 | column: 54 303 | }, 304 | end: { 305 | line: 1, 306 | column: 55 307 | } 308 | }, 309 | range: [54, 55] 310 | }, 311 | { 312 | type: 'Punctuator', 313 | value: ')', 314 | start: 56, 315 | end: 57, 316 | loc: { 317 | start: { 318 | line: 1, 319 | column: 56 320 | }, 321 | end: { 322 | line: 1, 323 | column: 57 324 | } 325 | }, 326 | range: [56, 57] 327 | }, 328 | { 329 | type: 'Punctuator', 330 | value: '=>', 331 | start: 58, 332 | end: 60, 333 | loc: { 334 | start: { 335 | line: 1, 336 | column: 58 337 | }, 338 | end: { 339 | line: 1, 340 | column: 60 341 | } 342 | }, 343 | range: [58, 60] 344 | }, 345 | { 346 | type: 'Punctuator', 347 | value: '{', 348 | start: 61, 349 | end: 62, 350 | loc: { 351 | start: { 352 | line: 1, 353 | column: 61 354 | }, 355 | end: { 356 | line: 1, 357 | column: 62 358 | } 359 | }, 360 | range: [61, 62] 361 | }, 362 | { 363 | type: 'Identifier', 364 | value: 'lambda', 365 | start: 63, 366 | end: 69, 367 | loc: { 368 | start: { 369 | line: 1, 370 | column: 63 371 | }, 372 | end: { 373 | line: 1, 374 | column: 69 375 | } 376 | }, 377 | range: [63, 69] 378 | }, 379 | { 380 | type: 'Punctuator', 381 | value: '(', 382 | start: 69, 383 | end: 70, 384 | loc: { 385 | start: { 386 | line: 1, 387 | column: 69 388 | }, 389 | end: { 390 | line: 1, 391 | column: 70 392 | } 393 | }, 394 | range: [69, 70] 395 | }, 396 | { 397 | type: 'Punctuator', 398 | value: ')', 399 | start: 70, 400 | end: 71, 401 | loc: { 402 | start: { 403 | line: 1, 404 | column: 70 405 | }, 406 | end: { 407 | line: 1, 408 | column: 71 409 | } 410 | }, 411 | range: [70, 71] 412 | }, 413 | { 414 | type: 'Punctuator', 415 | value: ';', 416 | start: 71, 417 | end: 72, 418 | loc: { 419 | start: { 420 | line: 1, 421 | column: 71 422 | }, 423 | end: { 424 | line: 1, 425 | column: 72 426 | } 427 | }, 428 | range: [71, 72] 429 | }, 430 | { 431 | type: 'Punctuator', 432 | value: '}', 433 | start: 73, 434 | end: 74, 435 | loc: { 436 | start: { 437 | line: 1, 438 | column: 73 439 | }, 440 | end: { 441 | line: 1, 442 | column: 74 443 | } 444 | }, 445 | range: [73, 74] 446 | }, 447 | { 448 | type: 'Punctuator', 449 | value: '}', 450 | start: 74, 451 | end: 75, 452 | loc: { 453 | start: { 454 | line: 1, 455 | column: 74 456 | }, 457 | end: { 458 | line: 1, 459 | column: 75 460 | } 461 | }, 462 | range: [74, 75] 463 | } 464 | ], 465 | sourceType: 'module', 466 | directives: undefined, 467 | body: [{ 468 | type: 'ClassDeclaration', 469 | start: 0, 470 | end: 75, 471 | loc: { 472 | start: { 473 | line: 1, 474 | column: 0 475 | }, 476 | end: { 477 | line: 1, 478 | column: 75 479 | } 480 | }, 481 | range: [0, 75], 482 | id: { 483 | type: 'Identifier', 484 | start: 6, 485 | end: 9, 486 | loc: { 487 | start: { 488 | line: 1, 489 | column: 6 490 | }, 491 | end: { 492 | line: 1, 493 | column: 9 494 | }, 495 | identifierName: 'Foo' 496 | }, 497 | range: [6, 9], 498 | name: 'Foo', 499 | _babelType: 'Identifier', 500 | }, 501 | superClass: null, 502 | body: { 503 | type: 'ClassBody', 504 | start: 10, 505 | end: 75, 506 | loc: { 507 | start: { 508 | line: 1, 509 | column: 10 510 | }, 511 | end: { 512 | line: 1, 513 | column: 75 514 | } 515 | }, 516 | range: [10, 75], 517 | body: [{ 518 | type: 'ClassProperty', 519 | start: 12, 520 | end: 74, 521 | loc: { 522 | start: { 523 | line: 1, 524 | column: 12 525 | }, 526 | end: { 527 | line: 1, 528 | column: 74 529 | } 530 | }, 531 | range: [12, 74], 532 | static: false, 533 | key: { 534 | type: 'Identifier', 535 | start: 12, 536 | end: 15, 537 | loc: { 538 | start: { 539 | line: 1, 540 | column: 12 541 | }, 542 | end: { 543 | line: 1, 544 | column: 15 545 | }, 546 | identifierName: 'foo' 547 | }, 548 | range: [12, 15], 549 | name: 'foo', 550 | _babelType: 'Identifier', 551 | }, 552 | computed: false, 553 | variance: null, 554 | value: { 555 | type: 'ArrowFunctionExpression', 556 | start: 18, 557 | end: 74, 558 | loc: { 559 | start: { 560 | line: 1, 561 | column: 18 562 | }, 563 | end: { 564 | line: 1, 565 | column: 74 566 | } 567 | }, 568 | range: [18, 74], 569 | id: null, 570 | generator: false, 571 | async: true, 572 | expression: false, 573 | params: [{ 574 | type: 'Identifier', 575 | start: 26, 576 | end: 55, 577 | loc: { 578 | start: { 579 | line: 1, 580 | column: 26 581 | }, 582 | end: { 583 | line: 1, 584 | column: 55 585 | }, 586 | identifierName: 'lambda' 587 | }, 588 | range: [26, 55], 589 | name: 'lambda', 590 | typeAnnotation: { 591 | type: 'TypeAnnotation', 592 | start: 32, 593 | end: 55, 594 | loc: { 595 | start: { 596 | line: 1, 597 | column: 32 598 | }, 599 | end: { 600 | line: 1, 601 | column: 55 602 | } 603 | }, 604 | range: [32, 55], 605 | typeAnnotation: { 606 | type: 'FunctionTypeAnnotation', 607 | start: 35, 608 | end: 54, 609 | loc: { 610 | start: { 611 | line: 1, 612 | column: 35 613 | }, 614 | end: { 615 | line: 1, 616 | column: 54 617 | } 618 | }, 619 | range: [35, 54], 620 | params: [{ 621 | type: 'FunctionTypeParam', 622 | start: 35, 623 | end: 41, 624 | loc: { 625 | start: { 626 | line: 1, 627 | column: 35 628 | }, 629 | end: { 630 | line: 1, 631 | column: 41 632 | } 633 | }, 634 | range: [35, 41], 635 | optional: false, 636 | typeAnnotation: { 637 | type: 'VoidTypeAnnotation', 638 | start: 35, 639 | end: 39, 640 | loc: { 641 | start: { 642 | line: 1, 643 | column: 35 644 | }, 645 | end: { 646 | line: 1, 647 | column: 39 648 | } 649 | }, 650 | range: [35, 39], 651 | _babelType: 'VoidTypeAnnotation', 652 | }, 653 | _babelType: 'FunctionTypeParam', 654 | }], 655 | rest: null, 656 | returnType: { 657 | type: 'GenericTypeAnnotation', 658 | start: 41, 659 | end: 54, 660 | loc: { 661 | start: { 662 | line: 1, 663 | column: 41 664 | }, 665 | end: { 666 | line: 1, 667 | column: 54 668 | } 669 | }, 670 | range: [41, 54], 671 | typeParameters: { 672 | type: 'TypeParameterInstantiation', 673 | start: 48, 674 | end: 54, 675 | loc: { 676 | start: { 677 | line: 1, 678 | column: 48 679 | }, 680 | end: { 681 | line: 1, 682 | column: 54 683 | } 684 | }, 685 | range: [48, 54], 686 | params: [{ 687 | type: 'VoidTypeAnnotation', 688 | start: 49, 689 | end: 53, 690 | loc: { 691 | start: { 692 | line: 1, 693 | column: 49 694 | }, 695 | end: { 696 | line: 1, 697 | column: 53 698 | } 699 | }, 700 | range: [49, 53], 701 | _babelType: 'VoidTypeAnnotation', 702 | }], 703 | _babelType: 'TypeParameterInstantiation', 704 | }, 705 | id: { 706 | type: 'Identifier', 707 | start: 41, 708 | end: 48, 709 | loc: { 710 | start: { 711 | line: 1, 712 | column: 41 713 | }, 714 | end: { 715 | line: 1, 716 | column: 48 717 | }, 718 | identifierName: 'Promise' 719 | }, 720 | range: [41, 48], 721 | name: 'Promise', 722 | _babelType: 'Identifier', 723 | }, 724 | _babelType: 'GenericTypeAnnotation', 725 | }, 726 | typeParameters: null, 727 | _babelType: 'FunctionTypeAnnotation', 728 | }, 729 | _babelType: 'TypeAnnotation', 730 | }, 731 | _babelType: 'Identifier', 732 | }], 733 | body: { 734 | type: 'BlockStatement', 735 | start: 61, 736 | end: 74, 737 | loc: { 738 | start: { 739 | line: 1, 740 | column: 61 741 | }, 742 | end: { 743 | line: 1, 744 | column: 74 745 | } 746 | }, 747 | range: [61, 74], 748 | body: [{ 749 | type: 'ExpressionStatement', 750 | start: 63, 751 | end: 72, 752 | loc: { 753 | start: { 754 | line: 1, 755 | column: 63 756 | }, 757 | end: { 758 | line: 1, 759 | column: 72 760 | } 761 | }, 762 | range: [63, 72], 763 | expression: { 764 | type: 'CallExpression', 765 | start: 63, 766 | end: 71, 767 | loc: { 768 | start: { 769 | line: 1, 770 | column: 63 771 | }, 772 | end: { 773 | line: 1, 774 | column: 71 775 | } 776 | }, 777 | range: [63, 71], 778 | callee: { 779 | type: 'Identifier', 780 | start: 63, 781 | end: 69, 782 | loc: { 783 | start: { 784 | line: 1, 785 | column: 63 786 | }, 787 | end: { 788 | line: 1, 789 | column: 69 790 | }, 791 | identifierName: 'lambda' 792 | }, 793 | range: [63, 69], 794 | name: 'lambda', 795 | _babelType: 'Identifier', 796 | }, 797 | arguments: [], 798 | _babelType: 'CallExpression', 799 | }, 800 | _babelType: 'ExpressionStatement', 801 | }], 802 | _babelType: 'BlockStatement', 803 | }, 804 | _babelType: 'ArrowFunctionExpression', 805 | }, 806 | _babelType: 'ClassProperty', 807 | }], 808 | _babelType: 'ClassBody', 809 | }, 810 | _babelType: 'ClassDeclaration', 811 | }], 812 | }); 813 | -------------------------------------------------------------------------------- /tests/fixtures/parsers/no-floating-promise/floating-promise-typed-identifier.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Source code: 3 | * function foo(): Promise { return Promise.resolve(); }; async function wrap() { foo(); } 4 | */ 5 | 6 | exports.parse = () => ({ 7 | type: 'Program', 8 | start: 0, 9 | end: 93, 10 | loc: { 11 | start: { 12 | line: 1, 13 | column: 0 14 | }, 15 | end: { 16 | line: 1, 17 | column: 93 18 | } 19 | }, 20 | range: [0, 93], 21 | comments: [], 22 | tokens: [{ 23 | type: 'Keyword', 24 | value: 'function', 25 | start: 0, 26 | end: 8, 27 | loc: { 28 | start: { 29 | line: 1, 30 | column: 0 31 | }, 32 | end: { 33 | line: 1, 34 | column: 8 35 | } 36 | }, 37 | range: [0, 8] 38 | }, 39 | { 40 | type: 'Identifier', 41 | value: 'foo', 42 | start: 9, 43 | end: 12, 44 | loc: { 45 | start: { 46 | line: 1, 47 | column: 9 48 | }, 49 | end: { 50 | line: 1, 51 | column: 12 52 | } 53 | }, 54 | range: [9, 12] 55 | }, 56 | { 57 | type: 'Punctuator', 58 | value: '(', 59 | start: 12, 60 | end: 13, 61 | loc: { 62 | start: { 63 | line: 1, 64 | column: 12 65 | }, 66 | end: { 67 | line: 1, 68 | column: 13 69 | } 70 | }, 71 | range: [12, 13] 72 | }, 73 | { 74 | type: 'Punctuator', 75 | value: ')', 76 | start: 13, 77 | end: 14, 78 | loc: { 79 | start: { 80 | line: 1, 81 | column: 13 82 | }, 83 | end: { 84 | line: 1, 85 | column: 14 86 | } 87 | }, 88 | range: [13, 14] 89 | }, 90 | { 91 | type: 'Punctuator', 92 | value: ':', 93 | start: 14, 94 | end: 15, 95 | loc: { 96 | start: { 97 | line: 1, 98 | column: 14 99 | }, 100 | end: { 101 | line: 1, 102 | column: 15 103 | } 104 | }, 105 | range: [14, 15] 106 | }, 107 | { 108 | type: 'Identifier', 109 | value: 'Promise', 110 | start: 16, 111 | end: 23, 112 | loc: { 113 | start: { 114 | line: 1, 115 | column: 16 116 | }, 117 | end: { 118 | line: 1, 119 | column: 23 120 | } 121 | }, 122 | range: [16, 23] 123 | }, 124 | { 125 | type: 'Punctuator', 126 | value: '<', 127 | start: 23, 128 | end: 24, 129 | loc: { 130 | start: { 131 | line: 1, 132 | column: 23 133 | }, 134 | end: { 135 | line: 1, 136 | column: 24 137 | } 138 | }, 139 | range: [23, 24] 140 | }, 141 | { 142 | type: 'Keyword', 143 | value: 'void', 144 | start: 24, 145 | end: 28, 146 | loc: { 147 | start: { 148 | line: 1, 149 | column: 24 150 | }, 151 | end: { 152 | line: 1, 153 | column: 28 154 | } 155 | }, 156 | range: [24, 28] 157 | }, 158 | { 159 | type: 'Punctuator', 160 | value: '>', 161 | start: 28, 162 | end: 29, 163 | loc: { 164 | start: { 165 | line: 1, 166 | column: 28 167 | }, 168 | end: { 169 | line: 1, 170 | column: 29 171 | } 172 | }, 173 | range: [28, 29] 174 | }, 175 | { 176 | type: 'Punctuator', 177 | value: '{', 178 | start: 30, 179 | end: 31, 180 | loc: { 181 | start: { 182 | line: 1, 183 | column: 30 184 | }, 185 | end: { 186 | line: 1, 187 | column: 31 188 | } 189 | }, 190 | range: [30, 31] 191 | }, 192 | { 193 | type: 'Keyword', 194 | value: 'return', 195 | start: 32, 196 | end: 38, 197 | loc: { 198 | start: { 199 | line: 1, 200 | column: 32 201 | }, 202 | end: { 203 | line: 1, 204 | column: 38 205 | } 206 | }, 207 | range: [32, 38] 208 | }, 209 | { 210 | type: 'Identifier', 211 | value: 'Promise', 212 | start: 39, 213 | end: 46, 214 | loc: { 215 | start: { 216 | line: 1, 217 | column: 39 218 | }, 219 | end: { 220 | line: 1, 221 | column: 46 222 | } 223 | }, 224 | range: [39, 46] 225 | }, 226 | { 227 | type: 'Punctuator', 228 | value: '.', 229 | start: 46, 230 | end: 47, 231 | loc: { 232 | start: { 233 | line: 1, 234 | column: 46 235 | }, 236 | end: { 237 | line: 1, 238 | column: 47 239 | } 240 | }, 241 | range: [46, 47] 242 | }, 243 | { 244 | type: 'Identifier', 245 | value: 'resolve', 246 | start: 47, 247 | end: 54, 248 | loc: { 249 | start: { 250 | line: 1, 251 | column: 47 252 | }, 253 | end: { 254 | line: 1, 255 | column: 54 256 | } 257 | }, 258 | range: [47, 54] 259 | }, 260 | { 261 | type: 'Punctuator', 262 | value: '(', 263 | start: 54, 264 | end: 55, 265 | loc: { 266 | start: { 267 | line: 1, 268 | column: 54 269 | }, 270 | end: { 271 | line: 1, 272 | column: 55 273 | } 274 | }, 275 | range: [54, 55] 276 | }, 277 | { 278 | type: 'Punctuator', 279 | value: ')', 280 | start: 55, 281 | end: 56, 282 | loc: { 283 | start: { 284 | line: 1, 285 | column: 55 286 | }, 287 | end: { 288 | line: 1, 289 | column: 56 290 | } 291 | }, 292 | range: [55, 56] 293 | }, 294 | { 295 | type: 'Punctuator', 296 | value: ';', 297 | start: 56, 298 | end: 57, 299 | loc: { 300 | start: { 301 | line: 1, 302 | column: 56 303 | }, 304 | end: { 305 | line: 1, 306 | column: 57 307 | } 308 | }, 309 | range: [56, 57] 310 | }, 311 | { 312 | type: 'Punctuator', 313 | value: '}', 314 | start: 58, 315 | end: 59, 316 | loc: { 317 | start: { 318 | line: 1, 319 | column: 58 320 | }, 321 | end: { 322 | line: 1, 323 | column: 59 324 | } 325 | }, 326 | range: [58, 59] 327 | }, 328 | { 329 | type: 'Punctuator', 330 | value: ';', 331 | start: 59, 332 | end: 60, 333 | loc: { 334 | start: { 335 | line: 1, 336 | column: 59 337 | }, 338 | end: { 339 | line: 1, 340 | column: 60 341 | } 342 | }, 343 | range: [59, 60] 344 | }, 345 | { 346 | type: 'Identifier', 347 | value: 'async', 348 | start: 61, 349 | end: 66, 350 | loc: { 351 | start: { 352 | line: 1, 353 | column: 61 354 | }, 355 | end: { 356 | line: 1, 357 | column: 66 358 | } 359 | }, 360 | range: [61, 66] 361 | }, 362 | { 363 | type: 'Keyword', 364 | value: 'function', 365 | start: 67, 366 | end: 75, 367 | loc: { 368 | start: { 369 | line: 1, 370 | column: 67 371 | }, 372 | end: { 373 | line: 1, 374 | column: 75 375 | } 376 | }, 377 | range: [67, 75] 378 | }, 379 | { 380 | type: 'Identifier', 381 | value: 'wrap', 382 | start: 76, 383 | end: 80, 384 | loc: { 385 | start: { 386 | line: 1, 387 | column: 76 388 | }, 389 | end: { 390 | line: 1, 391 | column: 80 392 | } 393 | }, 394 | range: [76, 80] 395 | }, 396 | { 397 | type: 'Punctuator', 398 | value: '(', 399 | start: 80, 400 | end: 81, 401 | loc: { 402 | start: { 403 | line: 1, 404 | column: 80 405 | }, 406 | end: { 407 | line: 1, 408 | column: 81 409 | } 410 | }, 411 | range: [80, 81] 412 | }, 413 | { 414 | type: 'Punctuator', 415 | value: ')', 416 | start: 81, 417 | end: 82, 418 | loc: { 419 | start: { 420 | line: 1, 421 | column: 81 422 | }, 423 | end: { 424 | line: 1, 425 | column: 82 426 | } 427 | }, 428 | range: [81, 82] 429 | }, 430 | { 431 | type: 'Punctuator', 432 | value: '{', 433 | start: 83, 434 | end: 84, 435 | loc: { 436 | start: { 437 | line: 1, 438 | column: 83 439 | }, 440 | end: { 441 | line: 1, 442 | column: 84 443 | } 444 | }, 445 | range: [83, 84] 446 | }, 447 | { 448 | type: 'Identifier', 449 | value: 'foo', 450 | start: 85, 451 | end: 88, 452 | loc: { 453 | start: { 454 | line: 1, 455 | column: 85 456 | }, 457 | end: { 458 | line: 1, 459 | column: 88 460 | } 461 | }, 462 | range: [85, 88] 463 | }, 464 | { 465 | type: 'Punctuator', 466 | value: '(', 467 | start: 88, 468 | end: 89, 469 | loc: { 470 | start: { 471 | line: 1, 472 | column: 88 473 | }, 474 | end: { 475 | line: 1, 476 | column: 89 477 | } 478 | }, 479 | range: [88, 89] 480 | }, 481 | { 482 | type: 'Punctuator', 483 | value: ')', 484 | start: 89, 485 | end: 90, 486 | loc: { 487 | start: { 488 | line: 1, 489 | column: 89 490 | }, 491 | end: { 492 | line: 1, 493 | column: 90 494 | } 495 | }, 496 | range: [89, 90] 497 | }, 498 | { 499 | type: 'Punctuator', 500 | value: ';', 501 | start: 90, 502 | end: 91, 503 | loc: { 504 | start: { 505 | line: 1, 506 | column: 90 507 | }, 508 | end: { 509 | line: 1, 510 | column: 91 511 | } 512 | }, 513 | range: [90, 91] 514 | }, 515 | { 516 | type: 'Punctuator', 517 | value: '}', 518 | start: 92, 519 | end: 93, 520 | loc: { 521 | start: { 522 | line: 1, 523 | column: 92 524 | }, 525 | end: { 526 | line: 1, 527 | column: 93 528 | } 529 | }, 530 | range: [92, 93] 531 | } 532 | ], 533 | sourceType: 'module', 534 | directives: undefined, 535 | body: [{ 536 | type: 'FunctionDeclaration', 537 | start: 0, 538 | end: 59, 539 | loc: { 540 | start: { 541 | line: 1, 542 | column: 0 543 | }, 544 | end: { 545 | line: 1, 546 | column: 59 547 | } 548 | }, 549 | range: [0, 59], 550 | id: { 551 | type: 'Identifier', 552 | start: 9, 553 | end: 12, 554 | loc: { 555 | start: { 556 | line: 1, 557 | column: 9 558 | }, 559 | end: { 560 | line: 1, 561 | column: 12 562 | }, 563 | identifierName: 'foo' 564 | }, 565 | range: [9, 12], 566 | name: 'foo', 567 | _babelType: 'Identifier', 568 | }, 569 | generator: false, 570 | async: false, 571 | expression: false, 572 | params: [], 573 | predicate: null, 574 | returnType: { 575 | type: 'TypeAnnotation', 576 | start: 14, 577 | end: 29, 578 | loc: { 579 | start: { 580 | line: 1, 581 | column: 14 582 | }, 583 | end: { 584 | line: 1, 585 | column: 29 586 | } 587 | }, 588 | range: [14, 29], 589 | typeAnnotation: { 590 | type: 'GenericTypeAnnotation', 591 | start: 16, 592 | end: 29, 593 | loc: { 594 | start: { 595 | line: 1, 596 | column: 16 597 | }, 598 | end: { 599 | line: 1, 600 | column: 29 601 | } 602 | }, 603 | range: [16, 29], 604 | typeParameters: { 605 | type: 'TypeParameterInstantiation', 606 | start: 23, 607 | end: 29, 608 | loc: { 609 | start: { 610 | line: 1, 611 | column: 23 612 | }, 613 | end: { 614 | line: 1, 615 | column: 29 616 | } 617 | }, 618 | range: [23, 29], 619 | params: [{ 620 | type: 'VoidTypeAnnotation', 621 | start: 24, 622 | end: 28, 623 | loc: { 624 | start: { 625 | line: 1, 626 | column: 24 627 | }, 628 | end: { 629 | line: 1, 630 | column: 28 631 | } 632 | }, 633 | range: [24, 28], 634 | _babelType: 'VoidTypeAnnotation', 635 | }], 636 | _babelType: 'TypeParameterInstantiation', 637 | }, 638 | id: { 639 | type: 'Identifier', 640 | start: 16, 641 | end: 23, 642 | loc: { 643 | start: { 644 | line: 1, 645 | column: 16 646 | }, 647 | end: { 648 | line: 1, 649 | column: 23 650 | }, 651 | identifierName: 'Promise' 652 | }, 653 | range: [16, 23], 654 | name: 'Promise', 655 | _babelType: 'Identifier', 656 | }, 657 | _babelType: 'GenericTypeAnnotation', 658 | }, 659 | _babelType: 'TypeAnnotation', 660 | }, 661 | body: { 662 | type: 'BlockStatement', 663 | start: 30, 664 | end: 59, 665 | loc: { 666 | start: { 667 | line: 1, 668 | column: 30 669 | }, 670 | end: { 671 | line: 1, 672 | column: 59 673 | } 674 | }, 675 | range: [30, 59], 676 | body: [{ 677 | type: 'ReturnStatement', 678 | start: 32, 679 | end: 57, 680 | loc: { 681 | start: { 682 | line: 1, 683 | column: 32 684 | }, 685 | end: { 686 | line: 1, 687 | column: 57 688 | } 689 | }, 690 | range: [32, 57], 691 | argument: { 692 | type: 'CallExpression', 693 | start: 39, 694 | end: 56, 695 | loc: { 696 | start: { 697 | line: 1, 698 | column: 39 699 | }, 700 | end: { 701 | line: 1, 702 | column: 56 703 | } 704 | }, 705 | range: [39, 56], 706 | callee: { 707 | type: 'MemberExpression', 708 | start: 39, 709 | end: 54, 710 | loc: { 711 | start: { 712 | line: 1, 713 | column: 39 714 | }, 715 | end: { 716 | line: 1, 717 | column: 54 718 | } 719 | }, 720 | range: [39, 54], 721 | object: { 722 | type: 'Identifier', 723 | start: 39, 724 | end: 46, 725 | loc: { 726 | start: { 727 | line: 1, 728 | column: 39 729 | }, 730 | end: { 731 | line: 1, 732 | column: 46 733 | }, 734 | identifierName: 'Promise' 735 | }, 736 | range: [39, 46], 737 | name: 'Promise', 738 | _babelType: 'Identifier', 739 | }, 740 | property: { 741 | type: 'Identifier', 742 | start: 47, 743 | end: 54, 744 | loc: { 745 | start: { 746 | line: 1, 747 | column: 47 748 | }, 749 | end: { 750 | line: 1, 751 | column: 54 752 | }, 753 | identifierName: 'resolve' 754 | }, 755 | range: [47, 54], 756 | name: 'resolve', 757 | _babelType: 'Identifier', 758 | }, 759 | computed: false, 760 | _babelType: 'MemberExpression', 761 | }, 762 | arguments: [], 763 | _babelType: 'CallExpression', 764 | }, 765 | _babelType: 'ReturnStatement', 766 | }], 767 | _babelType: 'BlockStatement', 768 | }, 769 | _babelType: 'FunctionDeclaration', 770 | }, 771 | { 772 | type: 'EmptyStatement', 773 | start: 59, 774 | end: 60, 775 | loc: { 776 | start: { 777 | line: 1, 778 | column: 59 779 | }, 780 | end: { 781 | line: 1, 782 | column: 60 783 | } 784 | }, 785 | range: [59, 60], 786 | _babelType: 'EmptyStatement', 787 | }, 788 | { 789 | type: 'FunctionDeclaration', 790 | start: 61, 791 | end: 93, 792 | loc: { 793 | start: { 794 | line: 1, 795 | column: 61 796 | }, 797 | end: { 798 | line: 1, 799 | column: 93 800 | } 801 | }, 802 | range: [61, 93], 803 | id: { 804 | type: 'Identifier', 805 | start: 76, 806 | end: 80, 807 | loc: { 808 | start: { 809 | line: 1, 810 | column: 76 811 | }, 812 | end: { 813 | line: 1, 814 | column: 80 815 | }, 816 | identifierName: 'wrap' 817 | }, 818 | range: [76, 80], 819 | name: 'wrap', 820 | _babelType: 'Identifier', 821 | }, 822 | generator: false, 823 | async: true, 824 | expression: false, 825 | params: [], 826 | body: { 827 | type: 'BlockStatement', 828 | start: 83, 829 | end: 93, 830 | loc: { 831 | start: { 832 | line: 1, 833 | column: 83 834 | }, 835 | end: { 836 | line: 1, 837 | column: 93 838 | } 839 | }, 840 | range: [83, 93], 841 | body: [{ 842 | type: 'ExpressionStatement', 843 | start: 85, 844 | end: 91, 845 | loc: { 846 | start: { 847 | line: 1, 848 | column: 85 849 | }, 850 | end: { 851 | line: 1, 852 | column: 91 853 | } 854 | }, 855 | range: [85, 91], 856 | expression: { 857 | type: 'CallExpression', 858 | start: 85, 859 | end: 90, 860 | loc: { 861 | start: { 862 | line: 1, 863 | column: 85 864 | }, 865 | end: { 866 | line: 1, 867 | column: 90 868 | } 869 | }, 870 | range: [85, 90], 871 | callee: { 872 | type: 'Identifier', 873 | start: 85, 874 | end: 88, 875 | loc: { 876 | start: { 877 | line: 1, 878 | column: 85 879 | }, 880 | end: { 881 | line: 1, 882 | column: 88 883 | }, 884 | identifierName: 'foo' 885 | }, 886 | range: [85, 88], 887 | name: 'foo', 888 | _babelType: 'Identifier', 889 | }, 890 | arguments: [], 891 | _babelType: 'CallExpression', 892 | }, 893 | _babelType: 'ExpressionStatement', 894 | }], 895 | _babelType: 'BlockStatement', 896 | }, 897 | _babelType: 'FunctionDeclaration', 898 | } 899 | ], 900 | }); 901 | -------------------------------------------------------------------------------- /tests/fixtures/parsers/no-floating-promise/floating-promise-typed-expression.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Source code: 3 | * async function wrap() { (function (): Promise { return Promise.resolve(); })(); }; 4 | */ 5 | 6 | exports.parse = () => ({ 7 | type: 'Program', 8 | start: 0, 9 | end: 87, 10 | loc: { 11 | start: { 12 | line: 1, 13 | column: 0 14 | }, 15 | end: { 16 | line: 1, 17 | column: 87 18 | } 19 | }, 20 | range: [0, 87], 21 | comments: [], 22 | tokens: [{ 23 | type: 'Identifier', 24 | value: 'async', 25 | start: 0, 26 | end: 5, 27 | loc: { 28 | start: { 29 | line: 1, 30 | column: 0 31 | }, 32 | end: { 33 | line: 1, 34 | column: 5 35 | } 36 | }, 37 | range: [0, 5] 38 | }, 39 | { 40 | type: 'Keyword', 41 | value: 'function', 42 | start: 6, 43 | end: 14, 44 | loc: { 45 | start: { 46 | line: 1, 47 | column: 6 48 | }, 49 | end: { 50 | line: 1, 51 | column: 14 52 | } 53 | }, 54 | range: [6, 14] 55 | }, 56 | { 57 | type: 'Identifier', 58 | value: 'wrap', 59 | start: 15, 60 | end: 19, 61 | loc: { 62 | start: { 63 | line: 1, 64 | column: 15 65 | }, 66 | end: { 67 | line: 1, 68 | column: 19 69 | } 70 | }, 71 | range: [15, 19] 72 | }, 73 | { 74 | type: 'Punctuator', 75 | value: '(', 76 | start: 19, 77 | end: 20, 78 | loc: { 79 | start: { 80 | line: 1, 81 | column: 19 82 | }, 83 | end: { 84 | line: 1, 85 | column: 20 86 | } 87 | }, 88 | range: [19, 20] 89 | }, 90 | { 91 | type: 'Punctuator', 92 | value: ')', 93 | start: 20, 94 | end: 21, 95 | loc: { 96 | start: { 97 | line: 1, 98 | column: 20 99 | }, 100 | end: { 101 | line: 1, 102 | column: 21 103 | } 104 | }, 105 | range: [20, 21] 106 | }, 107 | { 108 | type: 'Punctuator', 109 | value: '{', 110 | start: 22, 111 | end: 23, 112 | loc: { 113 | start: { 114 | line: 1, 115 | column: 22 116 | }, 117 | end: { 118 | line: 1, 119 | column: 23 120 | } 121 | }, 122 | range: [22, 23] 123 | }, 124 | { 125 | type: 'Punctuator', 126 | value: '(', 127 | start: 24, 128 | end: 25, 129 | loc: { 130 | start: { 131 | line: 1, 132 | column: 24 133 | }, 134 | end: { 135 | line: 1, 136 | column: 25 137 | } 138 | }, 139 | range: [24, 25] 140 | }, 141 | { 142 | type: 'Keyword', 143 | value: 'function', 144 | start: 25, 145 | end: 33, 146 | loc: { 147 | start: { 148 | line: 1, 149 | column: 25 150 | }, 151 | end: { 152 | line: 1, 153 | column: 33 154 | } 155 | }, 156 | range: [25, 33] 157 | }, 158 | { 159 | type: 'Punctuator', 160 | value: '(', 161 | start: 34, 162 | end: 35, 163 | loc: { 164 | start: { 165 | line: 1, 166 | column: 34 167 | }, 168 | end: { 169 | line: 1, 170 | column: 35 171 | } 172 | }, 173 | range: [34, 35] 174 | }, 175 | { 176 | type: 'Punctuator', 177 | value: ')', 178 | start: 35, 179 | end: 36, 180 | loc: { 181 | start: { 182 | line: 1, 183 | column: 35 184 | }, 185 | end: { 186 | line: 1, 187 | column: 36 188 | } 189 | }, 190 | range: [35, 36] 191 | }, 192 | { 193 | type: 'Punctuator', 194 | value: ':', 195 | start: 36, 196 | end: 37, 197 | loc: { 198 | start: { 199 | line: 1, 200 | column: 36 201 | }, 202 | end: { 203 | line: 1, 204 | column: 37 205 | } 206 | }, 207 | range: [36, 37] 208 | }, 209 | { 210 | type: 'Identifier', 211 | value: 'Promise', 212 | start: 38, 213 | end: 45, 214 | loc: { 215 | start: { 216 | line: 1, 217 | column: 38 218 | }, 219 | end: { 220 | line: 1, 221 | column: 45 222 | } 223 | }, 224 | range: [38, 45] 225 | }, 226 | { 227 | type: 'Punctuator', 228 | value: '<', 229 | start: 45, 230 | end: 46, 231 | loc: { 232 | start: { 233 | line: 1, 234 | column: 45 235 | }, 236 | end: { 237 | line: 1, 238 | column: 46 239 | } 240 | }, 241 | range: [45, 46] 242 | }, 243 | { 244 | type: 'Keyword', 245 | value: 'void', 246 | start: 46, 247 | end: 50, 248 | loc: { 249 | start: { 250 | line: 1, 251 | column: 46 252 | }, 253 | end: { 254 | line: 1, 255 | column: 50 256 | } 257 | }, 258 | range: [46, 50] 259 | }, 260 | { 261 | type: 'Punctuator', 262 | value: '>', 263 | start: 50, 264 | end: 51, 265 | loc: { 266 | start: { 267 | line: 1, 268 | column: 50 269 | }, 270 | end: { 271 | line: 1, 272 | column: 51 273 | } 274 | }, 275 | range: [50, 51] 276 | }, 277 | { 278 | type: 'Punctuator', 279 | value: '{', 280 | start: 52, 281 | end: 53, 282 | loc: { 283 | start: { 284 | line: 1, 285 | column: 52 286 | }, 287 | end: { 288 | line: 1, 289 | column: 53 290 | } 291 | }, 292 | range: [52, 53] 293 | }, 294 | { 295 | type: 'Keyword', 296 | value: 'return', 297 | start: 54, 298 | end: 60, 299 | loc: { 300 | start: { 301 | line: 1, 302 | column: 54 303 | }, 304 | end: { 305 | line: 1, 306 | column: 60 307 | } 308 | }, 309 | range: [54, 60] 310 | }, 311 | { 312 | type: 'Identifier', 313 | value: 'Promise', 314 | start: 61, 315 | end: 68, 316 | loc: { 317 | start: { 318 | line: 1, 319 | column: 61 320 | }, 321 | end: { 322 | line: 1, 323 | column: 68 324 | } 325 | }, 326 | range: [61, 68] 327 | }, 328 | { 329 | type: 'Punctuator', 330 | value: '.', 331 | start: 68, 332 | end: 69, 333 | loc: { 334 | start: { 335 | line: 1, 336 | column: 68 337 | }, 338 | end: { 339 | line: 1, 340 | column: 69 341 | } 342 | }, 343 | range: [68, 69] 344 | }, 345 | { 346 | type: 'Identifier', 347 | value: 'resolve', 348 | start: 69, 349 | end: 76, 350 | loc: { 351 | start: { 352 | line: 1, 353 | column: 69 354 | }, 355 | end: { 356 | line: 1, 357 | column: 76 358 | } 359 | }, 360 | range: [69, 76] 361 | }, 362 | { 363 | type: 'Punctuator', 364 | value: '(', 365 | start: 76, 366 | end: 77, 367 | loc: { 368 | start: { 369 | line: 1, 370 | column: 76 371 | }, 372 | end: { 373 | line: 1, 374 | column: 77 375 | } 376 | }, 377 | range: [76, 77] 378 | }, 379 | { 380 | type: 'Punctuator', 381 | value: ')', 382 | start: 77, 383 | end: 78, 384 | loc: { 385 | start: { 386 | line: 1, 387 | column: 77 388 | }, 389 | end: { 390 | line: 1, 391 | column: 78 392 | } 393 | }, 394 | range: [77, 78] 395 | }, 396 | { 397 | type: 'Punctuator', 398 | value: ';', 399 | start: 78, 400 | end: 79, 401 | loc: { 402 | start: { 403 | line: 1, 404 | column: 78 405 | }, 406 | end: { 407 | line: 1, 408 | column: 79 409 | } 410 | }, 411 | range: [78, 79] 412 | }, 413 | { 414 | type: 'Punctuator', 415 | value: '}', 416 | start: 80, 417 | end: 81, 418 | loc: { 419 | start: { 420 | line: 1, 421 | column: 80 422 | }, 423 | end: { 424 | line: 1, 425 | column: 81 426 | } 427 | }, 428 | range: [80, 81] 429 | }, 430 | { 431 | type: 'Punctuator', 432 | value: ')', 433 | start: 81, 434 | end: 82, 435 | loc: { 436 | start: { 437 | line: 1, 438 | column: 81 439 | }, 440 | end: { 441 | line: 1, 442 | column: 82 443 | } 444 | }, 445 | range: [81, 82] 446 | }, 447 | { 448 | type: 'Punctuator', 449 | value: '(', 450 | start: 82, 451 | end: 83, 452 | loc: { 453 | start: { 454 | line: 1, 455 | column: 82 456 | }, 457 | end: { 458 | line: 1, 459 | column: 83 460 | } 461 | }, 462 | range: [82, 83] 463 | }, 464 | { 465 | type: 'Punctuator', 466 | value: ')', 467 | start: 83, 468 | end: 84, 469 | loc: { 470 | start: { 471 | line: 1, 472 | column: 83 473 | }, 474 | end: { 475 | line: 1, 476 | column: 84 477 | } 478 | }, 479 | range: [83, 84] 480 | }, 481 | { 482 | type: 'Punctuator', 483 | value: ';', 484 | start: 84, 485 | end: 85, 486 | loc: { 487 | start: { 488 | line: 1, 489 | column: 84 490 | }, 491 | end: { 492 | line: 1, 493 | column: 85 494 | } 495 | }, 496 | range: [84, 85] 497 | }, 498 | { 499 | type: 'Punctuator', 500 | value: '}', 501 | start: 86, 502 | end: 87, 503 | loc: { 504 | start: { 505 | line: 1, 506 | column: 86 507 | }, 508 | end: { 509 | line: 1, 510 | column: 87 511 | } 512 | }, 513 | range: [86, 87] 514 | } 515 | ], 516 | sourceType: 'module', 517 | directives: undefined, 518 | body: [{ 519 | type: 'FunctionDeclaration', 520 | start: 0, 521 | end: 87, 522 | loc: { 523 | start: { 524 | line: 1, 525 | column: 0 526 | }, 527 | end: { 528 | line: 1, 529 | column: 87 530 | } 531 | }, 532 | range: [0, 87], 533 | id: { 534 | type: 'Identifier', 535 | start: 15, 536 | end: 19, 537 | loc: { 538 | start: { 539 | line: 1, 540 | column: 15 541 | }, 542 | end: { 543 | line: 1, 544 | column: 19 545 | }, 546 | identifierName: 'wrap' 547 | }, 548 | range: [15, 19], 549 | name: 'wrap', 550 | _babelType: 'Identifier', 551 | }, 552 | generator: false, 553 | async: true, 554 | expression: false, 555 | params: [], 556 | body: { 557 | type: 'BlockStatement', 558 | start: 22, 559 | end: 87, 560 | loc: { 561 | start: { 562 | line: 1, 563 | column: 22 564 | }, 565 | end: { 566 | line: 1, 567 | column: 87 568 | } 569 | }, 570 | range: [22, 87], 571 | body: [{ 572 | type: 'ExpressionStatement', 573 | start: 24, 574 | end: 85, 575 | loc: { 576 | start: { 577 | line: 1, 578 | column: 24 579 | }, 580 | end: { 581 | line: 1, 582 | column: 85 583 | } 584 | }, 585 | range: [24, 85], 586 | expression: { 587 | type: 'CallExpression', 588 | start: 24, 589 | end: 84, 590 | loc: { 591 | start: { 592 | line: 1, 593 | column: 24 594 | }, 595 | end: { 596 | line: 1, 597 | column: 84 598 | } 599 | }, 600 | range: [24, 84], 601 | callee: { 602 | type: 'FunctionExpression', 603 | start: 25, 604 | end: 81, 605 | loc: { 606 | start: { 607 | line: 1, 608 | column: 25 609 | }, 610 | end: { 611 | line: 1, 612 | column: 81 613 | } 614 | }, 615 | range: [25, 81], 616 | id: null, 617 | generator: false, 618 | async: false, 619 | expression: false, 620 | params: [], 621 | predicate: null, 622 | returnType: { 623 | type: 'TypeAnnotation', 624 | start: 36, 625 | end: 51, 626 | loc: { 627 | start: { 628 | line: 1, 629 | column: 36 630 | }, 631 | end: { 632 | line: 1, 633 | column: 51 634 | } 635 | }, 636 | range: [36, 51], 637 | typeAnnotation: { 638 | type: 'GenericTypeAnnotation', 639 | start: 38, 640 | end: 51, 641 | loc: { 642 | start: { 643 | line: 1, 644 | column: 38 645 | }, 646 | end: { 647 | line: 1, 648 | column: 51 649 | } 650 | }, 651 | range: [38, 51], 652 | typeParameters: { 653 | type: 'TypeParameterInstantiation', 654 | start: 45, 655 | end: 51, 656 | loc: { 657 | start: { 658 | line: 1, 659 | column: 45 660 | }, 661 | end: { 662 | line: 1, 663 | column: 51 664 | } 665 | }, 666 | range: [45, 51], 667 | params: [{ 668 | type: 'VoidTypeAnnotation', 669 | start: 46, 670 | end: 50, 671 | loc: { 672 | start: { 673 | line: 1, 674 | column: 46 675 | }, 676 | end: { 677 | line: 1, 678 | column: 50 679 | } 680 | }, 681 | range: [46, 50], 682 | _babelType: 'VoidTypeAnnotation', 683 | }], 684 | _babelType: 'TypeParameterInstantiation', 685 | }, 686 | id: { 687 | type: 'Identifier', 688 | start: 38, 689 | end: 45, 690 | loc: { 691 | start: { 692 | line: 1, 693 | column: 38 694 | }, 695 | end: { 696 | line: 1, 697 | column: 45 698 | }, 699 | identifierName: 'Promise' 700 | }, 701 | range: [38, 45], 702 | name: 'Promise', 703 | _babelType: 'Identifier', 704 | }, 705 | _babelType: 'GenericTypeAnnotation', 706 | }, 707 | _babelType: 'TypeAnnotation', 708 | }, 709 | body: { 710 | type: 'BlockStatement', 711 | start: 52, 712 | end: 81, 713 | loc: { 714 | start: { 715 | line: 1, 716 | column: 52 717 | }, 718 | end: { 719 | line: 1, 720 | column: 81 721 | } 722 | }, 723 | range: [52, 81], 724 | body: [{ 725 | type: 'ReturnStatement', 726 | start: 54, 727 | end: 79, 728 | loc: { 729 | start: { 730 | line: 1, 731 | column: 54 732 | }, 733 | end: { 734 | line: 1, 735 | column: 79 736 | } 737 | }, 738 | range: [54, 79], 739 | argument: { 740 | type: 'CallExpression', 741 | start: 61, 742 | end: 78, 743 | loc: { 744 | start: { 745 | line: 1, 746 | column: 61 747 | }, 748 | end: { 749 | line: 1, 750 | column: 78 751 | } 752 | }, 753 | range: [61, 78], 754 | callee: { 755 | type: 'MemberExpression', 756 | start: 61, 757 | end: 76, 758 | loc: { 759 | start: { 760 | line: 1, 761 | column: 61 762 | }, 763 | end: { 764 | line: 1, 765 | column: 76 766 | } 767 | }, 768 | range: [61, 76], 769 | object: { 770 | type: 'Identifier', 771 | start: 61, 772 | end: 68, 773 | loc: { 774 | start: { 775 | line: 1, 776 | column: 61 777 | }, 778 | end: { 779 | line: 1, 780 | column: 68 781 | }, 782 | identifierName: 'Promise' 783 | }, 784 | range: [61, 68], 785 | name: 'Promise', 786 | _babelType: 'Identifier', 787 | }, 788 | property: { 789 | type: 'Identifier', 790 | start: 69, 791 | end: 76, 792 | loc: { 793 | start: { 794 | line: 1, 795 | column: 69 796 | }, 797 | end: { 798 | line: 1, 799 | column: 76 800 | }, 801 | identifierName: 'resolve' 802 | }, 803 | range: [69, 76], 804 | name: 'resolve', 805 | _babelType: 'Identifier', 806 | }, 807 | computed: false, 808 | _babelType: 'MemberExpression', 809 | }, 810 | arguments: [], 811 | _babelType: 'CallExpression', 812 | }, 813 | _babelType: 'ReturnStatement', 814 | }], 815 | _babelType: 'BlockStatement', 816 | }, 817 | extra: { 818 | parenthesized: true, 819 | parenStart: 24 820 | }, 821 | _babelType: 'FunctionExpression', 822 | }, 823 | arguments: [], 824 | _babelType: 'CallExpression', 825 | }, 826 | _babelType: 'ExpressionStatement', 827 | }], 828 | _babelType: 'BlockStatement', 829 | }, 830 | _babelType: 'FunctionDeclaration', 831 | }], 832 | }); 833 | -------------------------------------------------------------------------------- /tests/fixtures/parsers/no-floating-promise/no-floating-promise-typed.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Source code: 3 | * function foo(): Promise { return Promise.resolve(); }; async function wrap() { await foo(); } 4 | */ 5 | 6 | exports.parse = () => ({ 7 | type: 'Program', 8 | start: 0, 9 | end: 99, 10 | loc: { 11 | start: { 12 | line: 1, 13 | column: 0 14 | }, 15 | end: { 16 | line: 1, 17 | column: 99 18 | } 19 | }, 20 | range: [0, 99], 21 | comments: [], 22 | tokens: [{ 23 | type: 'Keyword', 24 | value: 'function', 25 | start: 0, 26 | end: 8, 27 | loc: { 28 | start: { 29 | line: 1, 30 | column: 0 31 | }, 32 | end: { 33 | line: 1, 34 | column: 8 35 | } 36 | }, 37 | range: [0, 8] 38 | }, 39 | { 40 | type: 'Identifier', 41 | value: 'foo', 42 | start: 9, 43 | end: 12, 44 | loc: { 45 | start: { 46 | line: 1, 47 | column: 9 48 | }, 49 | end: { 50 | line: 1, 51 | column: 12 52 | } 53 | }, 54 | range: [9, 12] 55 | }, 56 | { 57 | type: 'Punctuator', 58 | value: '(', 59 | start: 12, 60 | end: 13, 61 | loc: { 62 | start: { 63 | line: 1, 64 | column: 12 65 | }, 66 | end: { 67 | line: 1, 68 | column: 13 69 | } 70 | }, 71 | range: [12, 13] 72 | }, 73 | { 74 | type: 'Punctuator', 75 | value: ')', 76 | start: 13, 77 | end: 14, 78 | loc: { 79 | start: { 80 | line: 1, 81 | column: 13 82 | }, 83 | end: { 84 | line: 1, 85 | column: 14 86 | } 87 | }, 88 | range: [13, 14] 89 | }, 90 | { 91 | type: 'Punctuator', 92 | value: ':', 93 | start: 14, 94 | end: 15, 95 | loc: { 96 | start: { 97 | line: 1, 98 | column: 14 99 | }, 100 | end: { 101 | line: 1, 102 | column: 15 103 | } 104 | }, 105 | range: [14, 15] 106 | }, 107 | { 108 | type: 'Identifier', 109 | value: 'Promise', 110 | start: 16, 111 | end: 23, 112 | loc: { 113 | start: { 114 | line: 1, 115 | column: 16 116 | }, 117 | end: { 118 | line: 1, 119 | column: 23 120 | } 121 | }, 122 | range: [16, 23] 123 | }, 124 | { 125 | type: 'Punctuator', 126 | value: '<', 127 | start: 23, 128 | end: 24, 129 | loc: { 130 | start: { 131 | line: 1, 132 | column: 23 133 | }, 134 | end: { 135 | line: 1, 136 | column: 24 137 | } 138 | }, 139 | range: [23, 24] 140 | }, 141 | { 142 | type: 'Keyword', 143 | value: 'void', 144 | start: 24, 145 | end: 28, 146 | loc: { 147 | start: { 148 | line: 1, 149 | column: 24 150 | }, 151 | end: { 152 | line: 1, 153 | column: 28 154 | } 155 | }, 156 | range: [24, 28] 157 | }, 158 | { 159 | type: 'Punctuator', 160 | value: '>', 161 | start: 28, 162 | end: 29, 163 | loc: { 164 | start: { 165 | line: 1, 166 | column: 28 167 | }, 168 | end: { 169 | line: 1, 170 | column: 29 171 | } 172 | }, 173 | range: [28, 29] 174 | }, 175 | { 176 | type: 'Punctuator', 177 | value: '{', 178 | start: 30, 179 | end: 31, 180 | loc: { 181 | start: { 182 | line: 1, 183 | column: 30 184 | }, 185 | end: { 186 | line: 1, 187 | column: 31 188 | } 189 | }, 190 | range: [30, 31] 191 | }, 192 | { 193 | type: 'Keyword', 194 | value: 'return', 195 | start: 32, 196 | end: 38, 197 | loc: { 198 | start: { 199 | line: 1, 200 | column: 32 201 | }, 202 | end: { 203 | line: 1, 204 | column: 38 205 | } 206 | }, 207 | range: [32, 38] 208 | }, 209 | { 210 | type: 'Identifier', 211 | value: 'Promise', 212 | start: 39, 213 | end: 46, 214 | loc: { 215 | start: { 216 | line: 1, 217 | column: 39 218 | }, 219 | end: { 220 | line: 1, 221 | column: 46 222 | } 223 | }, 224 | range: [39, 46] 225 | }, 226 | { 227 | type: 'Punctuator', 228 | value: '.', 229 | start: 46, 230 | end: 47, 231 | loc: { 232 | start: { 233 | line: 1, 234 | column: 46 235 | }, 236 | end: { 237 | line: 1, 238 | column: 47 239 | } 240 | }, 241 | range: [46, 47] 242 | }, 243 | { 244 | type: 'Identifier', 245 | value: 'resolve', 246 | start: 47, 247 | end: 54, 248 | loc: { 249 | start: { 250 | line: 1, 251 | column: 47 252 | }, 253 | end: { 254 | line: 1, 255 | column: 54 256 | } 257 | }, 258 | range: [47, 54] 259 | }, 260 | { 261 | type: 'Punctuator', 262 | value: '(', 263 | start: 54, 264 | end: 55, 265 | loc: { 266 | start: { 267 | line: 1, 268 | column: 54 269 | }, 270 | end: { 271 | line: 1, 272 | column: 55 273 | } 274 | }, 275 | range: [54, 55] 276 | }, 277 | { 278 | type: 'Punctuator', 279 | value: ')', 280 | start: 55, 281 | end: 56, 282 | loc: { 283 | start: { 284 | line: 1, 285 | column: 55 286 | }, 287 | end: { 288 | line: 1, 289 | column: 56 290 | } 291 | }, 292 | range: [55, 56] 293 | }, 294 | { 295 | type: 'Punctuator', 296 | value: ';', 297 | start: 56, 298 | end: 57, 299 | loc: { 300 | start: { 301 | line: 1, 302 | column: 56 303 | }, 304 | end: { 305 | line: 1, 306 | column: 57 307 | } 308 | }, 309 | range: [56, 57] 310 | }, 311 | { 312 | type: 'Punctuator', 313 | value: '}', 314 | start: 58, 315 | end: 59, 316 | loc: { 317 | start: { 318 | line: 1, 319 | column: 58 320 | }, 321 | end: { 322 | line: 1, 323 | column: 59 324 | } 325 | }, 326 | range: [58, 59] 327 | }, 328 | { 329 | type: 'Punctuator', 330 | value: ';', 331 | start: 59, 332 | end: 60, 333 | loc: { 334 | start: { 335 | line: 1, 336 | column: 59 337 | }, 338 | end: { 339 | line: 1, 340 | column: 60 341 | } 342 | }, 343 | range: [59, 60] 344 | }, 345 | { 346 | type: 'Identifier', 347 | value: 'async', 348 | start: 61, 349 | end: 66, 350 | loc: { 351 | start: { 352 | line: 1, 353 | column: 61 354 | }, 355 | end: { 356 | line: 1, 357 | column: 66 358 | } 359 | }, 360 | range: [61, 66] 361 | }, 362 | { 363 | type: 'Keyword', 364 | value: 'function', 365 | start: 67, 366 | end: 75, 367 | loc: { 368 | start: { 369 | line: 1, 370 | column: 67 371 | }, 372 | end: { 373 | line: 1, 374 | column: 75 375 | } 376 | }, 377 | range: [67, 75] 378 | }, 379 | { 380 | type: 'Identifier', 381 | value: 'wrap', 382 | start: 76, 383 | end: 80, 384 | loc: { 385 | start: { 386 | line: 1, 387 | column: 76 388 | }, 389 | end: { 390 | line: 1, 391 | column: 80 392 | } 393 | }, 394 | range: [76, 80] 395 | }, 396 | { 397 | type: 'Punctuator', 398 | value: '(', 399 | start: 80, 400 | end: 81, 401 | loc: { 402 | start: { 403 | line: 1, 404 | column: 80 405 | }, 406 | end: { 407 | line: 1, 408 | column: 81 409 | } 410 | }, 411 | range: [80, 81] 412 | }, 413 | { 414 | type: 'Punctuator', 415 | value: ')', 416 | start: 81, 417 | end: 82, 418 | loc: { 419 | start: { 420 | line: 1, 421 | column: 81 422 | }, 423 | end: { 424 | line: 1, 425 | column: 82 426 | } 427 | }, 428 | range: [81, 82] 429 | }, 430 | { 431 | type: 'Punctuator', 432 | value: '{', 433 | start: 83, 434 | end: 84, 435 | loc: { 436 | start: { 437 | line: 1, 438 | column: 83 439 | }, 440 | end: { 441 | line: 1, 442 | column: 84 443 | } 444 | }, 445 | range: [83, 84] 446 | }, 447 | { 448 | type: 'Identifier', 449 | value: 'await', 450 | start: 85, 451 | end: 90, 452 | loc: { 453 | start: { 454 | line: 1, 455 | column: 85 456 | }, 457 | end: { 458 | line: 1, 459 | column: 90 460 | } 461 | }, 462 | range: [85, 90] 463 | }, 464 | { 465 | type: 'Identifier', 466 | value: 'foo', 467 | start: 91, 468 | end: 94, 469 | loc: { 470 | start: { 471 | line: 1, 472 | column: 91 473 | }, 474 | end: { 475 | line: 1, 476 | column: 94 477 | } 478 | }, 479 | range: [91, 94] 480 | }, 481 | { 482 | type: 'Punctuator', 483 | value: '(', 484 | start: 94, 485 | end: 95, 486 | loc: { 487 | start: { 488 | line: 1, 489 | column: 94 490 | }, 491 | end: { 492 | line: 1, 493 | column: 95 494 | } 495 | }, 496 | range: [94, 95] 497 | }, 498 | { 499 | type: 'Punctuator', 500 | value: ')', 501 | start: 95, 502 | end: 96, 503 | loc: { 504 | start: { 505 | line: 1, 506 | column: 95 507 | }, 508 | end: { 509 | line: 1, 510 | column: 96 511 | } 512 | }, 513 | range: [95, 96] 514 | }, 515 | { 516 | type: 'Punctuator', 517 | value: ';', 518 | start: 96, 519 | end: 97, 520 | loc: { 521 | start: { 522 | line: 1, 523 | column: 96 524 | }, 525 | end: { 526 | line: 1, 527 | column: 97 528 | } 529 | }, 530 | range: [96, 97] 531 | }, 532 | { 533 | type: 'Punctuator', 534 | value: '}', 535 | start: 98, 536 | end: 99, 537 | loc: { 538 | start: { 539 | line: 1, 540 | column: 98 541 | }, 542 | end: { 543 | line: 1, 544 | column: 99 545 | } 546 | }, 547 | range: [98, 99] 548 | } 549 | ], 550 | sourceType: 'module', 551 | directives: undefined, 552 | body: [{ 553 | type: 'FunctionDeclaration', 554 | start: 0, 555 | end: 59, 556 | loc: { 557 | start: { 558 | line: 1, 559 | column: 0 560 | }, 561 | end: { 562 | line: 1, 563 | column: 59 564 | } 565 | }, 566 | range: [0, 59], 567 | id: { 568 | type: 'Identifier', 569 | start: 9, 570 | end: 12, 571 | loc: { 572 | start: { 573 | line: 1, 574 | column: 9 575 | }, 576 | end: { 577 | line: 1, 578 | column: 12 579 | }, 580 | identifierName: 'foo' 581 | }, 582 | range: [9, 12], 583 | name: 'foo', 584 | _babelType: 'Identifier', 585 | }, 586 | generator: false, 587 | async: false, 588 | expression: false, 589 | params: [], 590 | predicate: null, 591 | returnType: { 592 | type: 'TypeAnnotation', 593 | start: 14, 594 | end: 29, 595 | loc: { 596 | start: { 597 | line: 1, 598 | column: 14 599 | }, 600 | end: { 601 | line: 1, 602 | column: 29 603 | } 604 | }, 605 | range: [14, 29], 606 | typeAnnotation: { 607 | type: 'GenericTypeAnnotation', 608 | start: 16, 609 | end: 29, 610 | loc: { 611 | start: { 612 | line: 1, 613 | column: 16 614 | }, 615 | end: { 616 | line: 1, 617 | column: 29 618 | } 619 | }, 620 | range: [16, 29], 621 | typeParameters: { 622 | type: 'TypeParameterInstantiation', 623 | start: 23, 624 | end: 29, 625 | loc: { 626 | start: { 627 | line: 1, 628 | column: 23 629 | }, 630 | end: { 631 | line: 1, 632 | column: 29 633 | } 634 | }, 635 | range: [23, 29], 636 | params: [{ 637 | type: 'VoidTypeAnnotation', 638 | start: 24, 639 | end: 28, 640 | loc: { 641 | start: { 642 | line: 1, 643 | column: 24 644 | }, 645 | end: { 646 | line: 1, 647 | column: 28 648 | } 649 | }, 650 | range: [24, 28], 651 | _babelType: 'VoidTypeAnnotation', 652 | }], 653 | _babelType: 'TypeParameterInstantiation', 654 | }, 655 | id: { 656 | type: 'Identifier', 657 | start: 16, 658 | end: 23, 659 | loc: { 660 | start: { 661 | line: 1, 662 | column: 16 663 | }, 664 | end: { 665 | line: 1, 666 | column: 23 667 | }, 668 | identifierName: 'Promise' 669 | }, 670 | range: [16, 23], 671 | name: 'Promise', 672 | _babelType: 'Identifier', 673 | }, 674 | _babelType: 'GenericTypeAnnotation', 675 | }, 676 | _babelType: 'TypeAnnotation', 677 | }, 678 | body: { 679 | type: 'BlockStatement', 680 | start: 30, 681 | end: 59, 682 | loc: { 683 | start: { 684 | line: 1, 685 | column: 30 686 | }, 687 | end: { 688 | line: 1, 689 | column: 59 690 | } 691 | }, 692 | range: [30, 59], 693 | body: [{ 694 | type: 'ReturnStatement', 695 | start: 32, 696 | end: 57, 697 | loc: { 698 | start: { 699 | line: 1, 700 | column: 32 701 | }, 702 | end: { 703 | line: 1, 704 | column: 57 705 | } 706 | }, 707 | range: [32, 57], 708 | argument: { 709 | type: 'CallExpression', 710 | start: 39, 711 | end: 56, 712 | loc: { 713 | start: { 714 | line: 1, 715 | column: 39 716 | }, 717 | end: { 718 | line: 1, 719 | column: 56 720 | } 721 | }, 722 | range: [39, 56], 723 | callee: { 724 | type: 'MemberExpression', 725 | start: 39, 726 | end: 54, 727 | loc: { 728 | start: { 729 | line: 1, 730 | column: 39 731 | }, 732 | end: { 733 | line: 1, 734 | column: 54 735 | } 736 | }, 737 | range: [39, 54], 738 | object: { 739 | type: 'Identifier', 740 | start: 39, 741 | end: 46, 742 | loc: { 743 | start: { 744 | line: 1, 745 | column: 39 746 | }, 747 | end: { 748 | line: 1, 749 | column: 46 750 | }, 751 | identifierName: 'Promise' 752 | }, 753 | range: [39, 46], 754 | name: 'Promise', 755 | _babelType: 'Identifier', 756 | }, 757 | property: { 758 | type: 'Identifier', 759 | start: 47, 760 | end: 54, 761 | loc: { 762 | start: { 763 | line: 1, 764 | column: 47 765 | }, 766 | end: { 767 | line: 1, 768 | column: 54 769 | }, 770 | identifierName: 'resolve' 771 | }, 772 | range: [47, 54], 773 | name: 'resolve', 774 | _babelType: 'Identifier', 775 | }, 776 | computed: false, 777 | _babelType: 'MemberExpression', 778 | }, 779 | arguments: [], 780 | _babelType: 'CallExpression', 781 | }, 782 | _babelType: 'ReturnStatement', 783 | }], 784 | _babelType: 'BlockStatement', 785 | }, 786 | _babelType: 'FunctionDeclaration', 787 | }, 788 | { 789 | type: 'EmptyStatement', 790 | start: 59, 791 | end: 60, 792 | loc: { 793 | start: { 794 | line: 1, 795 | column: 59 796 | }, 797 | end: { 798 | line: 1, 799 | column: 60 800 | } 801 | }, 802 | range: [59, 60], 803 | _babelType: 'EmptyStatement', 804 | }, 805 | { 806 | type: 'FunctionDeclaration', 807 | start: 61, 808 | end: 99, 809 | loc: { 810 | start: { 811 | line: 1, 812 | column: 61 813 | }, 814 | end: { 815 | line: 1, 816 | column: 99 817 | } 818 | }, 819 | range: [61, 99], 820 | id: { 821 | type: 'Identifier', 822 | start: 76, 823 | end: 80, 824 | loc: { 825 | start: { 826 | line: 1, 827 | column: 76 828 | }, 829 | end: { 830 | line: 1, 831 | column: 80 832 | }, 833 | identifierName: 'wrap' 834 | }, 835 | range: [76, 80], 836 | name: 'wrap', 837 | _babelType: 'Identifier', 838 | }, 839 | generator: false, 840 | async: true, 841 | expression: false, 842 | params: [], 843 | body: { 844 | type: 'BlockStatement', 845 | start: 83, 846 | end: 99, 847 | loc: { 848 | start: { 849 | line: 1, 850 | column: 83 851 | }, 852 | end: { 853 | line: 1, 854 | column: 99 855 | } 856 | }, 857 | range: [83, 99], 858 | body: [{ 859 | type: 'ExpressionStatement', 860 | start: 85, 861 | end: 97, 862 | loc: { 863 | start: { 864 | line: 1, 865 | column: 85 866 | }, 867 | end: { 868 | line: 1, 869 | column: 97 870 | } 871 | }, 872 | range: [85, 97], 873 | expression: { 874 | type: 'AwaitExpression', 875 | start: 85, 876 | end: 96, 877 | loc: { 878 | start: { 879 | line: 1, 880 | column: 85 881 | }, 882 | end: { 883 | line: 1, 884 | column: 96 885 | } 886 | }, 887 | range: [85, 96], 888 | argument: { 889 | type: 'CallExpression', 890 | start: 91, 891 | end: 96, 892 | loc: { 893 | start: { 894 | line: 1, 895 | column: 91 896 | }, 897 | end: { 898 | line: 1, 899 | column: 96 900 | } 901 | }, 902 | range: [91, 96], 903 | callee: { 904 | type: 'Identifier', 905 | start: 91, 906 | end: 94, 907 | loc: { 908 | start: { 909 | line: 1, 910 | column: 91 911 | }, 912 | end: { 913 | line: 1, 914 | column: 94 915 | }, 916 | identifierName: 'foo' 917 | }, 918 | range: [91, 94], 919 | name: 'foo', 920 | _babelType: 'Identifier', 921 | }, 922 | arguments: [], 923 | _babelType: 'CallExpression', 924 | }, 925 | _babelType: 'AwaitExpression', 926 | }, 927 | _babelType: 'ExpressionStatement', 928 | }], 929 | _babelType: 'BlockStatement', 930 | }, 931 | _babelType: 'FunctionDeclaration', 932 | } 933 | ], 934 | }); 935 | --------------------------------------------------------------------------------