Support for declaring callback outside of define call
Opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
Rules using the getModules
util function don't work properly unless the second define
argument is a FunctionExpression
or ArrowFunctionExpression
. For example in the following code:
define(['N/record', './lib.js'], main);
function main(record, lib) {}
the no-module-extensions
rule would not catch the ".js" file extension.
Describe the solution you'd like
The ability for getModules
- and by extension all rules using this function - to support an Identifier
as the second define
argument and to find the definition of this callback to perform the validation currently done on the callback.
Describe alternatives you've considered
I've already created a fork that does this but it feels somewhat hacky and I can't currently afford to invest the time to learn enough about ESLint to do it "right" (I will still open a PR though, maybe it's a good start)
My initial thought was to try something with no-restricted-syntax
specifically to replace the no-module-extensions
rule and while I'm sure that's possible it doesn't fix the other rules affected.
Additional context
It would probably be a good idea to do this for the module list too, in case anyone writes their suitescript like
const modules = ['N/record', './lib'];
define(modules, main);
function main(record, lib) {}