return outside of functions
See original GitHub issueGiven:
// https://github.com/observing/pre-commit/blob/master/install.js#27
if (!exists(git) || !fs.lstatSync(git).isDirectory()) return;
I got a parse error:
SyntaxError: 'return' outside of function (1:54)
> 1 | if (!exists(git) || !fs.lstatSync(git).isDirectory()) return;
| ^
This is because return
is allowed within node modules but the parser does not like it.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
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 >Return Outside Function error in Python
Often, when one is confronted with a return outside function Python SyntaxError, it's due to improper indentation. Indentation tells Python that ...
Read more >Return outside function Python: How to Resolve SyntaxError
The SyntaxError: return outside function in Python occurs when you are using return. The SyntaxError suggests that you are not using the ...
Read more >Python return statement error " 'return' outside function"
The return statement only makes sense inside functions: def foo(): while True: return False.
Read more >SyntaxError: return not in function - JavaScript - MDN Web Docs
A return or yield statement is called outside of a function. Maybe there are missing curly brackets somewhere? The return and yield statements...
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 Free
Top 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
It seems like we shouldn’t allow then. We want to encourage only spec-compliant code and this is a very strange node feature.
this is another question, why need to support two parsers that give different output?