Parsing error: 'return' outside of function
See original GitHub issueCannot disable one line /* eslint-disable-next-line */
or even the whole file at the top with /* eslint-disable */
; both have no effect when the code contains a return
outside of the function:
if (condition) {
/* eslint-disable-next-line */
return; // ESLint always errors here, can't avoid it
}
And it always bombs out with error Parsing error: 'return' outside of function
.
I’m trying to add ESLint into a large test suit (jasmine) that’s been running successfully for years, and it uses the conditional return
-s as shown above to stop certain test execution under special conditions.
I’ve been struggling to figure out how to make ESLint disregard that one line without success.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
SyntaxError: return not in function - JavaScript - MDN Web Docs
The JavaScript exception "return (or yield) not in function" occurs when a return or yield statement is called outside of a function.
Read more >Error: 'return' outside of function in react js - Stack Overflow
Issue is semicolon after the render keyword. And render method is outside the class component due to wrongly placed brackets render(); {}.
Read more >SyntaxError: 'return' outside function - Codecademy
My indenting is fine, I think, even though the indenting doesn't show here. The error is: File “python”, line 7 SyntaxError: 'return' outside...
Read more >SyntaxError: script.js: 'return' outside of function `r` (6:4)
That's a syntax error, the function is supposed to wrap the rest of codes in. However, there's a few problems here.
Read more >Python SyntaxError: 'return' outside function Solution
The “SyntaxError: 'return' outside function” error is raised when you specify a return statement outside of a function. To solve this error, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is working as intended.
globalReturn
option cannot be used together with ES modules. Because both setting need special scope which is the child of the global scope.env: node
includesglobalReturn
option, so you don’t need specifying the option manually.eslint-disable
hides error reports from rules, but does not hide parsing errors of parsers.Closing because this is working as intended.