-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
extensions and no-unresolved with imports that don't have file extensions #2959
Comments
That should indeed work just fine. I notice you're not defining any settings, and the extensions rule isn't helping to enforce your extension preference. (I also notice you're using the recommended plugin (from the import and react plugins), which I discourage - you should be using the airbnb config) |
Thanks @ljharb, I'm not in a position now to change to airbnb config but may look at it in future. With my current extends, should this still work?
I would expect an import without a file extension to receive an error from the import/extensions rule, however I don't get one. |
Sorry ignore comment above, I didn't realise config on each rule goes in the settings section.
Edit .eslint.cjs
Now edit main.jsx & remove the ".jsx" extension from the import App line, eg At this point my expectation is that:
This is a basic example but I would like an eslint error from import/no-unresolved if, for example, the relative path to the resource is incorrect, but there shouldn't be an error if the path is correct & the .jsx file extension is missing. |
I may be missing something obvious here. In a react project, trying to get a linting error to display when the relative path to the resource is incorrect, but while still allowing the resource to not contain its extension.
Expected: no error expected when RVRModal.jxs exists at the relative path:
import RVRModal from "../../core/components/RVRModal";
Expected: error if there is an incorrect path:
import RVRModal from "../../core/incorrectpath/RVRModal";
Actual (when path is correct):
My .eslintrc:
If I add "import/no-unresolved": 0 to the rules, then the error disappears but then there is obviously no errors if I enter an invalid relative path to the resource either.
If I remove the "import/extensions": 0 rule, I am then forced to add the file extensions to all of my imports, which I would prefer not to do.
Is there a way for the no-unresolved to function alongside the extensions rule when extensions are disabled?
The text was updated successfully, but these errors were encountered: