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.

Docs: no-duplicate-imports - confusing option description and examples

See original GitHub issue

I’m working through the es6 docs (#5446) to make them more consistent and ran in to this:

http://eslint.org/docs/rules/no-duplicate-imports#options

I’ve not used ES6 import and export so I might be missing some pre-requisite knowledge, but the option description and examples are highly confusing to me. I get parse errors when pasting the code in to the online demo, so I can’t even tell which line of code would generate the rule violation.

Could someone with ES6 import / export knowledge help with improved description and examples?

As a start I think it might be beneficial to split the first option example in to two code blocks - or at least add a comment to denote to separate examples in the one block (I assume they are two separate examples due to the 3 blank lines in middle of example, or is it just a single example with extraneous line feeds?):

// example 1: <reason why this fails>
import { merge } from 'module';
import path from 'another-module'; // do we need this line?

export { find } from 'module';

// example 2: <reason why this fails>
import _ from 'module';
const find = _.find;

export { find as lodashFind } from 'module';

cc doc authors: @SimenB, @scriptdaemon

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Jun 18, 2016

See #6463

1reaction
pedrottimarkcommented, Jun 17, 2016

Ouch, been there, done that. Our pain becomes others’ gain. Trouble shooting a bit:

  • The Espree demo parses the code correctly with ECMA Version: 6 and Source Type: module
  • Unfortunately the ESLint demo has different options and it displays that error message even when I select the modules check box under ECMA Features. At least a limitation, probably an error.
  • As far as I know, there is no eslint comment to specify "sourceType": "module"

What I did was set up a project with configuration according to link below, copied example code to separate files, and then linted to verify expected errors for incorrect or no errors for correct either via command line or editor integration. For example, I use Atom editor with linter and linter-eslint community packages. The double-ouch was I set it and forgot it, and then later got confused by parsing errors in non-strict example code because modules have implicit strict mode.

If you keep a list of rule docs under ECMAScript 6 where this [EDIT: that is, "sourceType": "module" must be in ESLint configuration] happens, you can submit a future pull request to fix this issue by adding a sentence (to be determined) which includes the following link:

http://eslint.org/docs/user-guide/configuring#specifying-parser-options

That is an example of a chunk of content for the guidelines issue after the pull request is merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
eslint-plugin-import/no-duplicates.md at main - GitHub
eslint-plugin-import/docs/rules/no-duplicates.md. Go to file · Go to file T; Go to line L ... This rule is automatically fixable by the --fix CLI...
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 >
use prettier to resolve no-duplicate-imports eslint error
eslint has no-duplicate-imports https://eslint.org/docs/rules/no-duplicate-imports which shows error or warning for importing multiple ...
Read more >
no-duplicate-imports - Rule
Rule: no-duplicate-imports. Disallows multiple import statements from the same module. Rationale. Using a single import statement per module will make the ...
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