Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
176 views
in Technique[技术] by (71.8m points)

javascript - How to allow a "return outside of function" syntax when running npm test?

Basically I have a simple if statement in a file responsible for setting up some async queue behavior.

//queue.js file
if (!myEnv) {
  console.log('queue env is not set');
  return;
}

It's an old legacy NodeJs 12.18.x application and I want to allow the return statement to be valid syntax when I run npm test. Right now the test env spits out Syntax Error...return' outside of function'

Is there an easy workaround for this? The app is being sunsetted, so it doesn't make sense to turn this into a ton of work, just do the simplest solution and get out. If it helps there's an .eslintrc.js file and a .prettierrc.js file in the top level directory. Not sure if those files are impacting this error as it seems like from google it's a NodeJS error.

question from:https://stackoverflow.com/questions/65837723/how-to-allow-a-return-outside-of-function-syntax-when-running-npm-test

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...