question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[no-duplicate-imports] Treat namespace imports as different

See original GitHub issue

What rule do you want to change? no-duplicate-imports

Does this change cause the rule to produce more or fewer warnings? Reduces warnings.

How will the change be implemented? (New option, new default behavior, etc.)? Behavioural change, which could be either option controlled or new default behaviour. Prior art: TSLint.

Please provide some example code that this change will affect:

import * as parsers from '@src/parsers';
import { SpecificParser } from '@src/parsers';

What does the rule currently do for this code? Marks the imports as duplicates

What will the rule do after it’s changed? Not mark the imports as duplicates

Are you willing to submit a pull request to implement this change? Yes


The primary use I have for the above is with mocking in jest, such as here where I want to both use the parsers & also spy on them to test that specific ones are called.

While I can use destructuring, or reference off parsers, the former won’t be understood by auto-importers (i.e TS & IDE), and the latter would be inconsistent to how I use the functions in the rest of the codebase.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:32 (23 by maintainers)

github_iconTop GitHub Comments

4reactions
ljharbcommented, May 16, 2020

This remains a bug with an open PR; please reopen. cc @mdjermanovic

4reactions
kaicataldocommented, Jan 9, 2020

I think in general the behaviour of no-duplicate-imports should be “an import that can be merged with another is a duplicate of that other”.

This makes sense as a heuristic to me. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-duplicate-imports - Rule
Rule: no-duplicate-imports​​ Disallows multiple import statements from the same module.
Read more >
python - How should I avoid duplicate imports when writing ...
What you are doing is fine and how it's supposed to work and I wouldn't advise trying hard to hide your pandas import....
Read more >
no-duplicate-imports | typescript-eslint
Disallow duplicate imports. This rule has been deprecated in favour of the import/no-duplicates rule.
Read more >
no-duplicate-imports - ESLint - Pluggable JavaScript Linter
Rule Details. This rule requires that all imports from a single module that can be merged exist in a single import statement. Example...
Read more >
Traps for the Unwary in Python's Import System
While Python 3.3+ is able to import the submodule without any problems: ... the module namespace, and these are actually two different copies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found