Skip to content

An eslint plugin that helps you disallowing usage of deprecated variable by suggesting the matching one'

Notifications You must be signed in to change notification settings

frichti/eslint-plugin-no-deprecated-variable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-no-deprecated-variable

NPM JavaScript Style Guide

This plugin contains a rule that helps you to disallow usage of a variable and suggest you an autofix to replace it by its matching variable name

Installation

npm install --save-dev eslint-plugin-no-deprecated-variable

Usage

Prevent usage of specific deprecated variable.

For example, we want to prevent usage of DEPRECATED_COLORS variable and prefer usage of COLORS with a matching object of preferences.

We could setup our rule like that:

    "no-deprecated-variable": [
      2,
      {
        "properties": [{
          "deprecate": "DEPRECATED_COLORS",
          "matchingVariable": "COLORS",
          "matchObject": {
            "white": "light[900]",
            "secondary": "warning[500]",
          }
        }]
      }
    ],

With those options, the rule will trigger an error when we use DEPRECATED_COLORS and suggest to fix the error by replacing DEPRECATED_COLORS.white by COLORS.light[900].

👎 Examples of incorrect code for this rule (defined as above):

  /**
   * BAD
  */
  // file.js
  var color = DEPRECATED_COLORS.white;

👍 Examples of correct code for this rule (defined as above):

  /**
   * GOOD
  */
  // file.js
  var color = COLORS.light[900];

About

An eslint plugin that helps you disallowing usage of deprecated variable by suggesting the matching one'

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published