Is it possible to mark a project dependency as deprecated without removing it from the project.
So other developers don't use it in future
I have a project that was built on Material-UI V4 and have recently added Mui-V5 with the intention that all new work is built on V5. I'd like developers to see an IDE warning when they import components from the old dependency.
One thought I had is to use patch-package
to modify Mui-V4 and set it as deprecated in package.json but this warning only shows on npm install
.
Adding this as an answer, as the comment above worked great. ESLint's no-restricted-imports rule works great for deprecating external library imports.
It can be set as following (see the docs for more examples):
rules: {
// Deprecate redux
'no-restricted-imports': [
'warn',
{
paths: ['react-redux'],
},
],
}
This will show an IDE warning when importing anything from that module.
For deprecating local methods in your project, you can use the @deprecated
JSDoc tag which will also generate a strikethrough warning in the IDE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With