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
Idea: add a way of warning users about using deprecated functions #541
Comments
I think the best approach is to implement this as an attribute on plugins/commands. This will also expose one way for plugin authors to deprecate their plugins. The deprecation message should be shown for these scenarios (in the examples,
The best way to do it is probably to check inside @freitagbr what are your thoughts on turning deprecation warnings on by default? Or should we wait for the v0.9 release to have warnings on by default? |
I think we can turn them on by default for the next release. Deprecation warnings for node v7 itself are printed by default, anyway. |
Perhaps it would be nice to also include JSDoc deprecation tags, so that various JS-focused IDEs can hint to the developer of the deprecations. http://usejsdoc.org/tags-deprecated.html |
Speaking of JSDoc, it has become a sort of standard, so it would be useful to incorporate JSDoc comments in the code base. ShellJS uses a home-grown comment system that converts |
No deprecated commands yet, so I'm bumping this back a milestone. |
Let's put some more thought into solving this. I'd like to implement this with util.deprecate() if possible. We should use care that |
@freitagbr can you take this? It'd be good to have this finished shortly after #866. Removing the "breaking" label because this issue is about support for deprecating plugins, this does not track deprecating any particular plugin. |
Sure, I will tackle this. |
This adds a new wrap() option named `.deprecate`. This currently accepts a string value, which will be the deprecation message for the plugin. Deprecation works on standard commands as well as pipes. The call stack points directly to the deprecated method, and not to any ShellJS internals. Fixes #541 Test: This adds unit tests.
Once #524 is merged, it would be good to deprecate
shell.exec()
due to its vulnerabilities and bugs. While we can mark it as deprecated in the docs, since it's a security vulnerability, we may also want to provide deprecation warnings at runtime.However, since
exec()
still has a valid use case, I don't think we should ever get rid of it (so it's soft deprecation). Also, if we're still allowing people to use it, we should provide an API to skip deprecation warnings if they know what they're doing.One approach we could take:
shell.config.showDeprecationWarnings
(defaults to true)common
) to log a deprecation warning to stderr, only when the above option is trueThis idea is still open for discussion, so don't implement it yet until the "help wanted" label is applied.
The text was updated successfully, but these errors were encountered: