-
Notifications
You must be signed in to change notification settings - Fork 54
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 "Unable to resolve path to module" error in version 4.0 #91
Comments
This is an ESLint error, not a TypeScript error. It looks related to this issue: import-js/eslint-plugin-import#1739 The workaround that I'm using is to just omit the querystring by reverting the // vite.config.js
import { defineConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
export default defineConfig({
plugins: [svgr({ include: '**/*.svg' })],
}); Then you can import without import Close from './close.svg'; Alternativley, you can disable the ESLint rule for this specific case. The build will catch any missing SVG files and fail, but I prefer seeing the error through ESLint. // .eslintrc.js
module.exports = {
rules: {
'import/no-unresolved': ['error', { ignore: ['\\.svg\\?react$'] }]
},
}; |
@chrismeyers Using the proposal of :
When importing the SVG, the IDE thinks I am importing a string and not a component giving Typescript errors. |
@DevPowers Maybe try setting |
@DevPowers yeah what @chrismeyers said: you can add something like:
to your |
That got rid of the import warning but when using the SVG component I am still getting issues "Property style does not exist on type IntrinsicAttributes" I am using the component like this, and passing style to control the height and width of the SVG image:
For now I can use the eslint ignore option and just import using the ?react option, but it seems a bit hacky. Would be nice if it played nice with typescript and eslint out of the box |
using this |
I get a typescript error when try to import a svg like this:
import Close from './close.svg?react';
ESLint: Unable to resolve path to module './close.svg?react'.(import/no-unresolved)
The text was updated successfully, but these errors were encountered: