Sitelet https://github.com/import-js/eslint-plugin-import/issues/518
Skip to content

import/namespace does not support shadowing #518

Description

@Jessidhia

import/namespace does not detect when something in a closer scope shadows a namespace import, leading to bogus lint warnings.

This example is a bit bigger than necessary, but it is closer to the conditions where I encountered it:

import React, { PropTypes } from 'react'
import { createStructuredSelector } from 'reselect'
import { connect } from 'react-redux'
import * as todos from 'ducks/todos'

const mapStateToProps = createStructuredSelector({
  todos: todos.getTodos
})

const TodoApp = ({
  todos
}) => (
  <ol>
    {/* import/namespace 'map' not found in imported namespace 'todos' */}
    {todos.map(({ id }) => (<li key={id}>{id}</li>))}
  </ol>
)

const connected = connect(mapStateToProps)(TodoApp)
export { connected as TodoApp }

The same thing happens if I change the arrow function to start like props => { const { todos } = props; ..., or even props => { const todos = props.todos; ....

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions