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

Exports assignments not being picked up by no-unused-modules

Open paleite opened this issue 4 years ago • 7 comments

First of all, thanks for a great plugin! This has aided our team and saved us HOURS of debugging and it makes our imports and exports really consistent 🙂
I'm using export assignments (export = , see https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require ) in some of my TypeScript modules and no-unused-modules claims the modules aren't exporting anything.

Background, I'm writing my ESLint config in TypeScript, and want the compiled TypeScript code to say module.exports = eslintConfig

My ESLint config for the rule looks like this: "import/no-unused-modules": ["error", { missingExports: true }]

And the module looks like this:

index.ts:

const eslintConfig = {
  rules: {
    "import/no-unused-modules": ["error", { missingExports: true }],
  },
};

export = eslintConfig;

no-unused-modules with missingExports set to true will claim index.ts does not export a module.

paleite avatar Feb 01 '21 22:02 paleite

I think #1974 may have fixed this, but is not yet released.

ljharb avatar Feb 01 '21 22:02 ljharb

Interesting, but I'm not sure it's the same.

I looked through the PR, but I couldn't find anything regarding exports in there, only regarding imports.

Either way, I'll make sure to monitor the status of this. Thanks again 🙂

paleite avatar Feb 01 '21 22:02 paleite

It would be great if you wanted to create a PR with test cases - that would answer it immediately :-)

ljharb avatar Feb 02 '21 02:02 ljharb

I think this may be fixed, I tried to create a test case directly for it and it passes: https://github.com/ProdigySim/eslint-plugin-import/commit/308e8ca29623d9868919b66fb7e944d9fd6c516b

I am still having issues with exports of this style in my project, but it may be due to misconfiguration or outdated versions. I'll try to update here if I fix it.

ProdigySim avatar Apr 07 '22 13:04 ProdigySim

Thanks!

@paleite can you confirm? I'll reopen if it's still a problem for you.

ljharb avatar Apr 07 '22 13:04 ljharb

@ljharb actually, I think none of the TypeScript tests in named.js are wired up to actually run... it looks like the tests are collected in invalid/valid arrays but they are not run at all. So I was accidentally not running my test.

I pushed up another commit to run the tests and now my test case fails + another TS test is actually failing already:

https://github.com/import-js/eslint-plugin-import/commit/1e4d413f7ce74345e424c74196f54c35d7dcde53

ProdigySim avatar Apr 07 '22 13:04 ProdigySim

Opened a PR to run the current tests: https://github.com/import-js/eslint-plugin-import/pull/2427

ProdigySim avatar Apr 07 '22 14:04 ProdigySim