TypeScript - Mark npm package as deprecated in code base

31 views Asked by At

We have a code base in TypeScript and use various npm packages in it. The team has now decided to stop using one of these packages. Since it takes a while to remove it from our code, we want to mark it as deprecated.

So that developers get a hint like with functions that are marked as deprecated. In VSCode these functions are crossed out. Plus the note from the optional comment: "Don't use X, use Y instead."

Is that possible?

1

There are 1 answers

0
Mario Santini On BEST ANSWER

A good way to enforce check for libraries that are used in the codebase, is through eslint.

If you use the eslint-plugin-deprecate, as I mention in the comment, you can highlight the use of functions, member expressions, and imports as deprecated, and decide to show just a warning or throw an error and force to fix the build.

By using eslint rules, you can introduce automated checks in certain phases of the CI chain. And even provide each developer the tool in VSCode to see the error/warning of what is deprecated and should not be use, or should update.

Here the link to the complete documentation of the plugin:

https://www.npmjs.com/package/eslint-plugin-deprecate