Docs: no-duplicate-imports - confusing option description and examples
See original GitHub issueI’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:
- Created 7 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
See #6463
Ouch, been there, done that. Our pain becomes others’ gain. Trouble shooting a bit:
"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.