-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress filtered out reference warnings at the getReferences()
level?
#1287
Comments
let refs = getReferences(token.original.value, tokens, { unfilteredTokens, warnImmediately: false }) This option is mostly meant for when getReferences is used within the format lifecycle and you want the warnings to be collected and thrown later on once we've checked all tokens, but I guess in your case it might be useful to dodge the warnings as well. Otherwise you can always refer to this: https://styledictionary.com/reference/logging/ and set |
Yeah, but it doesn't really dodge them... it just puts the unwanted warnings at the end of the console, instead of the middle.
Yeah, but I only want to silence a particular usage... I do want the warnings for other usages (in the same output target). ... that being said, I suppose it is a very-specific, uncommon use case 🤷🏻 and sounds like I'm stuck with creating a specific "platform" for this output target and disable the logging. I'll miss out on potentially useful warnings for that one target, though. This might be pedantic... but, I do think it's a little odd that calling |
I think the reason of the oddness is that usually you are either calling getReferences:
Concluding, I agree that there should be a way to use getReferences, even within the format lifecycle, and not warn about filtered out refs when the intention isn't to output refs. I think in general, the logging capabilities of SD could be further improved by allowing you to specify the warn / verbosity options per log type rather than only for all logs. |
Hmmm... I didn't think about this... I could generate an inheritance tree object outside the format lifecycle, like as a pre-build step, I suppose, and just pull it in within the format lifecycle. A little smelly, but not horrible. 👍🏻
Yeah, that's where I was headed too... somewhat like I configure my |
Relates to #687
The logging configuration and mechanisms are much more robust in v4, but, I think I've encountered a non-trivial situation where it would be nice to be able to configure the logging at a more granular level, perhaps in a
File
config, or even at thegetReferences()
utility.From what I can tell, the warnings are issued when a call to
getReferences()
is made, not necessarily whenoutputReferences: true
.I have a few custom formats I've created where I'm not actually trying to "output references", but I do want to use
getReferences()
utility so I can actually get more token data and operate on it.For example, I have a trivial markdown formatter that outputs a token reference table as documentation. I use the
getReferences()
utility to help in generating a trivial "reference list" for each component. (This is probably the first step towards maybe generating a Graph at some point...)Anyway, Markdown is a static format, and there's really no such thing as a "broken reference", so in general, I don't really care if the references are filtered out, because I'm just trying to display them in an informational table, and I'm not actually "outputting references", because I'm just using the resolved value in the
Value
column. But, my console log gets "polluted" with a bunch of warnings because themy-size
, andmy-spacing
tokens have been filtered out (because I don't care to display them in the table, I just want the tokens at the "end of the chain" to be output).I could create an entirely
new StyleDictionary()
object, with logging turned off, just for using this custom markdown format, but that seems heavy-handed? Being able to configure the logging on a per-File output would be better...However, that being said, if I did want to change to
outputReferences: true
, so that the reference was in the Value column, I think it would in fact want to get those "filtered out" reference warnings... but only for thegetReferences()
call I used to generate the value, NOT thegetReferences()
call I use to generate the tree in the same file.The text was updated successfully, but these errors were encountered: