import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.46k stars 1.56k forks source link

no-unused-modules: in some cases, imports from files with capital letters in their names are not checked #1910

Open danyadev opened 3 years ago

danyadev commented 3 years ago

OS: Windows 10 Pro

The full eslint config and dependency versions can be viewed in the application repository. This bug is also reproduced there.

Perhaps this may also be due to the fact that the module itself is used in the .vue file.

Error:

C:\Users\danyadev\Desktop\vk-desktop\src\components\messages\chat\attachments\photosLayout.js
  97:1  error  exported declaration 'calculatePhotosLayout' not used within other modules  import/no-unused-modules

calculatePhotosLayout function is used in the same folder in PhotosLayout.vue file.

ljharb commented 3 years ago

I don't think this plugin could possibly work with .vue files - how would eslint-plugin-import know how to parse "not javascript"?

danyadev commented 3 years ago

this plugin works fine with all other .vue files in the project

ljharb commented 3 years ago

I'm not familiar with vue at all; do they use normal JS syntax for imports/exports? When you say "works fine", do you mean, it doesn't error on them, or do you mean, it reports errors inside them?

ljharb commented 3 years ago

To clarify the PR title - if you rename the file from PhotosLayout.vue to photosLayout.vue and update the corresponding import paths, does it work as expected?

danyadev commented 3 years ago

Sorry for the late answer, I left development for a while.

When changing the name of the .vue file, the problem is also reproduced:

image

danyadev commented 3 years ago

.vue files are handled entirely by vue-loader and its repository contains a description of how it works

"works fine" means that the plugin is actually monitoring the use of exports:

image image

TheJaredWilcurt commented 1 year ago

Same-ish problem. Inside of a .vue file the plugin will do things like enforce the order of imports, but if a .js file exports something that is only imported in .vue files, it will ignore them and think that there are no imports of it.

I tried renaming the .vue file to be all lowercase, but that didn't change anything.

// example.js
export function example () {
  return 'text';
}
<!-- myexample.vue -->
<template>
  <div>Text</div>
</template>

<script>
import { example } from './example.js';

console.log(example());

export default {
  name: 'MyExample'
};
</script>
C:\project\example.js
  2:1  error  exported declaration 'example' not used within other modules  import/no-unused-modules

Again, all other rules I'm using apply to .vue files, it's just this one that doesn't work.

Example project for reproduction:

fatyrify commented 2 months ago

same issue here, so this rule import/no-unused-modules still not working in .vue Githubissues.

  • Githubissues is a development platform for aggregating issues.