ota-meshi / eslint-plugin-astro

ESLint plugin for Astro component
https://ota-meshi.github.io/eslint-plugin-astro/
MIT License
304 stars 21 forks source link

Add notes on interop with eslint-plugin-import to docs #300

Open kavsingh opened 8 months ago

kavsingh commented 8 months ago

Description

One thing i always forget when setting up an astro project with eslint-plugin-astro + eslint-plugin-import, is how to resolve import/no-unresolved errors for astro:content.

My usual way of handling it is adding astro:content to core modules

"settings": {
  "import/core-modules": ["astro:content"]
}

Is that approach right, and would it be worth adding it (or the actual right thing to do) as a note in the configuration docs? Does it even belong in these docs?

ota-meshi commented 8 months ago

Pull requests are welcome! It would probably be good to include the following settings as well.

  "settings": {
    "import/parsers": {
      "astro-eslint-parser": [".astro"],
      "espree": [".js"],
      "...": [".ts", ...]
    }
  }
martinburger commented 8 months ago

After adding Astro View Transitions to my project, I encountered the following error:

error Unable to resolve path to module 'astro:transitions' import/no-unresolved

The above error is fixed by the following patch:

--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -66,8 +66,9 @@ module.exports = {
   settings: {
     'import/resolver': {
       typescript: {
         project: '.'
       }
-    }
+    },
+    'import/core-modules': ['astro:transitions']
   }
 }

Perhaps this will be of help to others.