eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

no-unused-modules "missingExports" returns false positives

Open Nantris opened this issue 4 years ago • 7 comments

I'd expect both of these cases to count as exports:

module.exports = {} // Should probably not trigger

export * from './someFile' // Should almost definitely not trigger

Nantris avatar May 27 '21 23:05 Nantris

module.exports = {} should definitely count.

export * from './someFile' should treat the module as if it had the same exports as someFile.

ljharb avatar May 27 '21 23:05 ljharb

Similar issue:

./index.js

  import { someName } from './foo';

./foo/index.js

  export * as someName from './bar'

results in "someNamed was not found in './foo'"

Nantris avatar May 31 '21 22:05 Nantris

I just removed an eslint-directive that I noted we'd needed due to this issue, but unless ESLint is doing something weird right now, it seems like this issue may be fixed in 2.25.x

If anyone else hits this, give the issue a bump and I'll re-open it.

Nantris avatar Dec 12 '21 01:12 Nantris

module.exports = {} should definitely count.

export * from './someFile' should treat the module as if it had the same exports as someFile.

Unfortunately it seems neither of these cases are actually resolved as of 2.26.0. I don't know what led me to believe they were. Perhaps I failed to re-enable the rule properly.

@ljharb any thoughts about possible causes and solutions?

Nantris avatar May 25 '22 21:05 Nantris

Our settings key in .eslintrc.js looks like this - I wonder if it's possibly related to resolution issues? But it seems to work fine in other capacities, so I'm doubtful.

settings: {
    // 'import/resolver': 'webpack',
    'import/cache': { lifetime: 0 },
    'import/external-module-folders': ['node_modules', 'packages'],
    'import/resolver': {
      'babel-module': {},
      webpack: {
        config: './webpack_config/webpack.config.resolve.js',
      },
    },
  },

Nantris avatar May 25 '22 21:05 Nantris

@Slapbox it might be that you're missing the node resolver - add that last, after webpack.

ljharb avatar Aug 27 '22 21:08 ljharb

Sorry for the lengthy absence here.

I finally got to give that a try but unfortunately it makes no difference.

I added

      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },

And installed eslint-import-resolver-node

Nantris avatar Apr 16 '23 18:04 Nantris