1.0.0 ā€¢ Published 3 years ago

eslint-plugin-no-deprecated-variable v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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];