Eslint-plugin-import: Support for named aggregate export pattern in import/name

Created on 10 May 2020  路  13Comments  路  Source: benmosher/eslint-plugin-import

_Apologies if this is ultimately the same bug as described in #1583 but it is a slightly different circumstance so I wanted to post it separately in case it is distinct_

Given:

// constants.js
export const x = 5
export const y = 6
// index.js
export * as constants from './constants'

The following is considered invalid:

// sandbox.js
import { constants } from './index'

Error:

ESLint: constants not found in './index' (import/named)

However, the following is considered valid

// sandbox.js
import * as blah from './index'

and indeed blah.constants is populated correctly.

My configuration:

{
  "extends": "airbnb-base",
  "parser": "babel-eslint",
  "rules": {
    "semi": [2, "never"],
    "indent": [2, "tab"],
    "no-tabs": 0
  },
  "env": {
    "es6": true,
    "node": true,
    "jest": true
  }
}

Eslint version: v6.8.0

bug help wanted

Most helpful comment

Seems like a clear bug, a PR to fix it is welcome (a PR with failing test cases is second-best, because that's much easier to fix than nothing)

All 13 comments

Seems like a clear bug, a PR to fix it is welcome (a PR with failing test cases is second-best, because that's much easier to fix than nothing)

Am also seeing this bug - if it helps I first started seeing it after upgrading eslint from 6.8.0 to 7.0.0 - rolling back to 6.8.0 fixes it

I tried writing a test.

... but it passes, which makes me wonder if maybe it isn't a bug with the plugin but maybe something else. I did attempt running the test against the most recent release (which my project is running) and it passed there too.

@jwld the plugin does not support eslint 7 until the next release.

@slifty what's your babel config?

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "node": "13.10"
        }
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-export-namespace-from"
  ]
}

I'd bet the export-namespace-from isn't something a released version of the plugin handles. Can you verify if the master branch of eslint-plugin-import fixes it?

Alas, loading directly from a built version of the master branch of eslint-plugin-import did not fix it. I'll try to figure out creating a locally failing test using the proposal-class-properties.

Side note this thread indicates that plugin is not going to be needed soon).


In order to simplify a bit, I created a repo completely separate from my original project (using eslint-plugin-import@master), which reproduces the problem.

This is the value of imports in named.js

ExportMap {
  path: '/Users/slifty/Code/NodeJS/eslint-sandbox/src/index.js',
  namespace: Map(0) {},
  reexports: Map(0) {},
  dependencies: Set(1) { [Function (anonymous)] },
  imports: Map(1) {
    '/Users/slifty/Code/NodeJS/eslint-sandbox/src/constants.js' => {
      getter: [Function (anonymous)],
      source: [Object],
      importedSpecifiers: Set(0) {}
    }
  },
  errors: [],
  mtime: 2020-05-14T18:56:05.014Z
}

A PR with failing test cases (or better, also with a fix) would be most appreciated :-)

Is there any news regarding this issue?

I'm have the same problem and using eslint 7.18

same here with "eslint": "^7.19.0",

There will continue to be no news or updates, and the problem will continue, until someone (a maintainer or a community member) posts a PR with failing tests and/or a fix. If that's not something you're willing or able to do, please feel free to emoji-react on the OP, but please do not notify a bunch of people with "me too" or "any updates?" posts.

Was this page helpful?
0 / 5 - 0 ratings