OverlayPlugin / cactbot

FFXIV TypeScript Raiding Overlay
Apache License 2.0
85 stars 34 forks source link

bug: eslint rule `cactbot-output-strings` doesn't detect spread properties #266

Open valarnin opened 1 month ago

valarnin commented 1 month ago

See commit https://github.com/OverlayPlugin/cactbot/pull/261/commits/f7606142f5de509e37e9f71e6fad539269051ca0, which added an explicit unknown key to the const-defined output strings map, despite the key existing on the Directions.outputStringsCardinalDir constant.

wexxlee commented 1 month ago

Ref: More info on issue in prior repo: https://github.com/quisquous/cactbot/issues/5538

MaikoTan commented 1 month ago

I think it CAN be done by reading the ImportDeclaration statement, then programmatically invoking TypeScript's parser to get the AST of that file, and then following the properties to get all its keys. But this is really painful to do such a thing. I am digging typescript declarations files, hoping this checking can be done by typescript itself rather than eslint.

valarnin commented 1 month ago

Even with the latest build of typescript, we can't force inference for this automatically, unfortunately.

It may make more sense to extract the ID of the trigger, then just import the triggerset directly and pull the computed outputStrings value from that, if we're dealing with it as a property (as opposed to cactbot-builtin-response setting it within the trigger).