
## Review A dedicated reviewer checked the rule description successfully for: - [x] logical errors and incorrect information - [x] information gaps and missing content - [x] text style and tone - [x] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
44 lines
1.4 KiB
Plaintext
44 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
On the principle that clearer code is better code, you should explicitly `import` the things you want to use in a module. Using ``++import *++`` imports everything in the module and risks confusing maintainers. Similarly, ``++export * from "module";++`` imports and then re-exports everything in the module and risks confusing not just maintainers but also the module's users.
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,javascript,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
import * as Imported from "aModule"; // Noncompliant
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,javascript,diff-id=1,diff-type=compliant]
|
|
----
|
|
import {aType, aFunction} from "aModule";
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Explicitly import the specific member needed.
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 5 Feb 2016, 15:31:27 Elena Vilchik wrote:
|
|
\[~ann.campbell.2] Actually there is no problems with scopes or name conflicts when using wildcard in JS: all you have imported are properties of `Imported`. So I would just remove first sentence and keep the second one reworked a bit: "Listing the necessary imports makes clear what's wanted."
|
|
|
|
=== on 5 Feb 2016, 16:39:27 Ann Campbell wrote:
|
|
See what you think now [~elena.vilchik]
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|