Skip to content

create-vue + airbnb gives unresolved path to 'vitest/config' #53

Open
@woodcoder

Description

Using create-vue to scaffold a vue3 JavaScript project with vitest using something like:

npm create [email protected]
yarn add --dev @vue/eslint-config-airbnb
vi vue-project/.eslintrc.cjs

Gives the following yarn lint error (amongst a couple of other, understandable syntax complaints):

vue-project/vitest.config.js
  3:46  error  Unable to resolve path to module 'vitest/config'  import/no-unresolved

However, running yarn vitest works - the import is fine.

I believe this is because the node_modules file is actually vitest/config.d.ts (which exports the js file in dist).
__

As a workaround I've been able to avoid the warning by specifying and adding .d.ts to the resolver's extensions in .eslintrc.cjs:

  settings: {
    'import/resolver': {
      node: {
        extensions: ['.vue', '.js', '.jsx', '.cjs', '.mjs', '.d.ts'],
      },
    },
  },

__

This is something that used to work without needing this extra config (I think when the vitest config in vue-create was placed directly in vite.config.js).

Is this a regression, an unsupported configuration, or have I found the correct fix and it just needs some extra documentation?

Many thanks.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions