|
STM doesn't have bandwidth to pick this up, so we're closing as won't fix. However, if other teams have capacity and would like to pursue this, please feel free to pick this up.
|
|
I've thought about this before and was hoping that template strings would give a nice way forward. However, I'm not sure there's a way to make use of template strings while still defining a function expression so that useful linting occurs. Instead, I've been thinking along the lines of having users defining a function that takes parameters and returning a string that represents calling that function with the state of the parameters passed in.
function functionToStringWithArgs(func, ...args) {
|
args = args.map(arg => tojson(arg));
|
|
if (args.length !== func.length) {
|
throw new Error('function expects ' + func.length + ' arguments, but found ' + args.length);
|
}
|
|
return "function() { (" + func.toString() + ")(" + args.toString() + "); }";
|
}
|
Instead of writing it as function(coll) {return coll.find()}, you could write it as something like
functionToStringWithArgs(function(dbName, collName) {
|
var coll = db.getSiblingDB(dbName)[collName];
|
coll.find();
|
}, coll.getDB().getName(), coll.getName());
|
However this still has the issue where if this function expression is defined within a context where coll is also defined, then omitting the coll declaration within the function wouldn't be an error from the linter's perspective, but only an error upon evaluating the function. On the upside, we'd get formatting and some linting with a way to pass additional data into startParallelShell()'d functions.
|