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

ESLint import/no-unresolved on 3.7.0 when importing with @-alias #22994

Closed
janericwinkelmann opened this issue Sep 4, 2023 · 5 comments
Closed

Comments

@janericwinkelmann
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v19.3.0
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.3
  • Nitro Version: 2.6.2
  • Package Manager: npm@9.2.0
  • Builder: -
  • User Config: runtimeConfig, css, nitro, vite, experimental, components, app, modules, i18n, build
  • Runtime Modules: @nuxtjs/tailwindcss@6.8.0
  • Build Modules: -

Reproduction

Create a new nuxt project, add a new custom folder and place a js file inside. Try to import this file. Enable linting and you should be able to reproduce the error on build.

Describe the bug

Prior to Nuxt 3.7.0 this was working fine. When importing a file from a non standard root level folder with the "@"-alias we now receive a linting error on build and on lint, but not when running nuxi dev:

import fragment from '@/shaders/fragment.glsl'
or
import math from '@/lib/math.js'

On build we than receive the error:
6:20 error Unable to resolve path to module '@/shaders/fragment.glsl' import/no-unresolved

When using
import fragment from '../shaders/fragment.glsl'
instead, everything's working fine.

Additional context

No response

Logs

No response

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@daspete
Copy link

daspete commented Sep 5, 2023

Same here, no alias imports are working.

@killjoy1221
Copy link

It seems to be related to the extends paired with the generated tsconfig.json no longer having a baseDir value. My quick fix is to specify the nuxt tsconfig in the eslint settings.

// .eslintrc
{
  "settings": {
    "import/resolver": {
      "typescript": {
        "project": "./.nuxt/tsconfig.json"
      }
    }
  }
}

Possibly related: dividab/tsconfig-paths#224

@leo-buneev
Copy link

Can confirm.
Source of the issue is package get-tsconfig, which eslint-import-resolver-typescript depends on
https://github.com/privatenumber/get-tsconfig/blob/develop/src/parse-tsconfig/index.ts

here when it resolves extended config it doesn't adjust relative values in compilerOptions.paths

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2023
@danielroe
Copy link
Member

Thanks for the debugging. This isn't a Nuxt issue, it seems, so I'm closing. But if you think there's something we should be doing, please feel free to let me know.

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

No branches or pull requests

5 participants