Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate named imports #16

Closed
JohnAlbin opened this issue Jun 10, 2020 · 1 comment
Closed

Deprecate named imports #16

JohnAlbin opened this issue Jun 10, 2020 · 1 comment
Assignees

Comments

@JohnAlbin
Copy link

JohnAlbin commented Jun 10, 2020

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.

@AlexMost
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants