Eslint-plugin-import: import/named: wildcard export not working?

Created on 23 Aug 2017  Â·  6Comments  Â·  Source: benmosher/eslint-plugin-import

Simplified version:
a.js:

    export const a = 5

b.js:

    export * from './a'

c.js:

    import {a} from './b' 

c.js errors with import/named: export a not found in b.js

however, when I try this simplified version, there is no error for c but it also doesn't error if I import x which definitely doesn't exist. So not sure what is going on…

bug help wanted

All 6 comments

* imports/exports cause all kinds of complexity; i'm sure this plugin probably just doesn't follow the ModuleRecords through transitively.

I have the same problem. Did you ever manage to reproduce it? Otherwise I could probably try creating a testcase where it happens...

yeah happening here as well. I swear i use this all the time but in the latest iterations its def not working anymore!

My current setup is about as simple as shown above

src/index.js

/* @flow */
export * from './es';

src/es.js

export function ping(requestTimeout?: number = 5000): Promise<void> {
  return client.ping({
    requestTimeout,
  });
}

test.js

/* @flow */
import { ping } from './src/index';

ping()
  .then(result => console.log('Ping Result: ', result))
  .catch(err => {
    console.log('Ping Error: ', err);
  });

image

As shown, Flow and Typescript both are picking it up.


     "babel-eslint": "^10.0.1",
     "eslint": "^5.9.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-flowtype": "^3.2.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-promise": "^4.0.1",
{
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 9,
    "sourceType": "module",
    "allowImportExportEverywhere": true
  },
  "extends": ["airbnb-base", "plugin:flowtype/recommended"],
  "env": {
    "node": true
  }
}

Update

On second check, I use export * from less than I thought and it doesnt seem to work anywhere. export * as ... does work although in this case it doesn't produce the desired result.

Also having this issue.

I was having this issue and fixed it by adding the TS resolver after Webpack:

settings:
  import/resolver:
    webpack: {}
    typescript: {}
  import/extensions: ['.js', '.ts', '.tsx']
  import/ignore: ['node_modules', 'src/js/', 'private_modules']
  import/parsers: {
    '@typescript-eslint/parser': ['.ts', '.tsx']
  }

I also thought it didn't work anywhere but it was specifically when it was outside of the areas for which I have webpack config.

So while I also initially thought it was a bug in the rule I think it was just due to resolution issues.

FWIW this test is specifically for export * from ... so this rule is definitely supposed to handle this. But if it can't resolve the deep file from the shallow file, you'll see things like you're seeing.

I found that if I directly import something from a lib, it won't be a problem.

But after re-exporting everything from the lib in another file (say util.js), then `import {xxx} from './util' will give the following error

xxx not found in './util' eslint(import/named)

Was this page helpful?
0 / 5 - 0 ratings