npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@silizia/eslint-plugin-deprecation

v3.1.0

Published

ESLint rule that reports usage of deprecated code

Downloads

10

Readme

eslint-plugin-deprecation

Test Workflow Release Workflow Maintainability Npm Npm Downloads Size License semantic-release

An ESLint plugin with rules reporting usage of deprecated code

Prerequisites

If you already use TypeScript and one or more rules from the typescript-eslint plugin, then eslint-plugin-deprecation will work out of the box without any additional dependencies or special configuration specified in this section. (This is because @typescript-eslint/plugin automatically contains @typescript-eslint/parser and your ESLint should already be configured with the parserOptions to work properly with TypeScript.)

Otherwise, in order for you to use this plugin, you must also install the following dependencies:

  • typescript
  • @typescript-eslint/parser

For example, if you use the npm package manager, then you would run the following command in the root of your project:

npm install --save-dev typescript @typescript-eslint/parser

Next, you must configure ESLint to parse TypeScript and include type information:

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "project": "./tsconfig.json" // <-- Point to your project's "tsconfig.json" or create a new one.
  }
}

Install

For example, if you use the npm package manager, then you would run the following command in the root of your project:

npm install --save-dev eslint-plugin-deprecation

Setup

Using the recommended Config

The easiest way to use this plugin is to extend from the recommended config, like this:

{
  "extends": [
    "plugin:deprecation/recommended",
  ],
}

The recommended config will enable the plugin and enable the deprecation/deprecation rule with a value of error.

Manually Enable the Plugin and Rule

If you don't want to use the recommended config for some reason, you can accomplish the same thing by specifying the following config:

{
  "plugins": [
    "deprecation",
  ],

  "rules": {
    "deprecation/deprecation": "error",
  },
}

Rules

Disallow usage of deprecated APIs (deprecation/deprecation)

Reports usage of any code marked with a @deprecated JSDoc tag.

For example, this includes browser APIs, Node.js APIs, library APIs and any other code that is marked with this tag.

Rule Details

Examples of incorrect code for this rule:

import { parse } from 'node:url';
import cheerio from 'cheerio';

// Node.js API
const url = parse('/foo'); // ❌ 'parse' is deprecated. Use the WHATWG URL API instead. eslint(deprecation/deprecation)

// Browser API
console.log(event?.bubbles); // ❌ 'event' is deprecated. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/event) eslint(deprecation/deprecation)

// Deprecated library API
cheerio('<h2 class="title">Hello world</h2>'); // ❌ 'cheerio' is deprecated. Use the function returned by `load` instead. eslint(deprecation/deprecation)

Examples of correct code for this rule:

import { load } from 'cheerio';
import { ChangeEvent } from 'react';

// Node.js API
const url2 = new URL('/foo', 'http://www.example.com'); // ✅ Modern Node.js API, uses `new URL()`

// Browser API
function onClick(event: ChangeEvent<HTMLInputElement>) {
  console.log(event.bubbles); // ✅ Modern browser API, does not use global
}

// Library API
load('<h2 class="title">Hello world</h2>'); // ✅ Allowed library API, uses named `load` import

Credits

This rule was originally ported from the SonarJS repository.