In an attempt to find unused translations in an application, I’d like to find all passed arguments to a function that can be statically determined. What’s the best way to go about this problem? Introspection? Using code mods or similar that can parse the AST?
Scenarios that I’d like to cover are e.g.:
translate("abc"); // "abc"
const arg = "abc"; translate(arg); // "abc"
const arg1 = "abc"; const arg2 = "xyz"; translate(arg1 + arg2); // "abcxyz"
const arg1 = "abc"; const arg2 = "xyz"; const arg = arg1 + arg2; translate(arg); // "abcxyz"
const arg = "abc"; const getArg = () => arg; translate(getArg()); // "abc"
If there are also non-static invocations on the form translate(getUserInput())
, then I’d be happy if I could get that as well as "getUserInput()"
or similar. But this scenario is not crucial.
I would like to get an array of all arguments, not having to “review search results” in the editor or terminal.
Any tips out there?