eslint-plugin-deprecate icon indicating copy to clipboard operation
eslint-plugin-deprecate copied to clipboard

Deprecate named imports

Open JohnAlbin opened this issue 5 years ago • 1 comments

Many times specific named exports are deprecated in a module, while other named exports are not deprecated. That means we can't use the existing 'deprecate/import' rule because its only parts of the module that are deprecated, not the entire module.

If we create a new eslint rule that allows us to name specific named exports to deprecate in a specific module, that would be super useful

If the eslint ruleset looked like this:

    'deprecate/import-name': [
      'error',
      { module: 'gatsby', name: 'navigate', use: 'utils/navigate' },
    ],

Then this javascript code would produce the following errors:

// Produces the error: 
// navigate from module gatsby is deprecated. Use utils/navigate instead
import { navigate } from 'gatsby';

// Produces the error:
// navigate from module gatsby is deprecated. Use utils/navigate instead
import { gql, navigate, Link } from 'gatsby';

// Produces no error
import { gql } from 'gatsby';

While this feature request is similar to #3, this rule would be linting the import of a method, not the usage of a method. Since it has become best practice to import specific names instead of the entire module, I feel this rule would be more useful than #3.

JohnAlbin avatar Jun 10 '20 06:06 JohnAlbin

Hi @JohnAlbin! That makes sense, will try to implement this feature.

AlexMost avatar Jun 15 '20 09:06 AlexMost