Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-duplicates fail positive #217

Closed
ntnyq opened this issue Dec 23, 2024 · 2 comments
Closed

no-duplicates fail positive #217

ntnyq opened this issue Dec 23, 2024 · 2 comments

Comments

@ntnyq
Copy link

ntnyq commented Dec 23, 2024

Repro repo

eslint-plugin-import-x: v4.6.1

ESLint config

import { config, configs  } from 'typescript-eslint'
import pluginImportX from 'eslint-plugin-import-x'

const { createNodeResolver } = pluginImportX

export default config({
  extends: [configs.recommended],
  plugins: {
    'import-x': pluginImportX
  },
  settings: {
    'import-x/resolver-next': [
      createNodeResolver({
        extensions: ['.js', '.mjs', '.ts', '.mts', '.d.ts', '.json'],
      }),
    ],
  },
  rules: {
    'import-x/no-duplicates': ['error']
  }
})

Code:

import { createRouter, createWebHashHistory } from 'vue-router'
import { routes } from 'vue-router/auto-routes'

export const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

Errors:

'/Users/ntnyq/Desktop/github/ntnyq/repro-import-x-no-duplicates/node_modules/.pnpm/[email protected][email protected][email protected]_/node_modules/vue-router/dist/vue-router.mjs' imported multiple times.

With --fix passed, code will change to:

import { createRouter, createWebHashHistory, routes } from 'vue-router'

export const router = createRouter({
  history: createWebHashHistory(),
  routes,
})
@JounQin
Copy link
Member

JounQin commented Dec 23, 2024

image

Their import/require conditions point to same file ./dist/vue-router.mjs, so they are considered duplicates.

If you use eslint-import-resolver-typescript, types condition will be preferred, then it should work as expected.

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2024
@ntnyq
Copy link
Author

ntnyq commented Dec 23, 2024

Got it. Thanks.

I'll try typescript resolver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants