In our app we have a few functions
that are public
because we need to call them from other classes, but that are meant to be used only in some specific cases because they perform sensitive operations. To decrease human error (developers using these functions when they shouldn’t), I thought it would be nice to display an ESLint
error when any of these functions are used, similar to what @deprecated
does. But I don’t want to use @deprecated
for this because the functions aren’t deprecated.
I was thinking it would be nice to have something like this in the JSDoc
of the function:
@restricted-usage Some description of why it's restricted.
When a function with this tag is used, an ESLint
error should be displayed, and the dev should add eslint-disable
if he really wants to use the function. I looked if I could use no-restricted-syntax
for this, but I think it doesn’t capture JSDoc
content.
What do you think of this approach? Is there anything I can use to achieve what I want or do I need to implement a custom eslint
plugin
to do this?