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-plugin-import: No default export of Astro component #259

Open
4 tasks done
arty-name opened this issue Nov 23, 2023 · 2 comments
Open
4 tasks done

eslint-plugin-import: No default export of Astro component #259

arty-name opened this issue Nov 23, 2023 · 2 comments

Comments

@arty-name
Copy link

arty-name commented Nov 23, 2023

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I'm using eslint-plugin-astro. (*.astro file linting does not work with the parser alone. You should also use eslint-plugin-astro with it.)
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-astro repo and open the issue in eslint-plugin-astro repo if there is no solution.
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.53.0

What version of eslint-plugin-astro and astro-eslint-parser are you using?

  • astro-eslint-parser@0.16.0
  • eslint-plugin-astro@0.29.1

What did you do?

Configuration
{
  "extends": [
    "standard-with-typescript",
    "plugin:import/recommended",
    "plugin:import/typescript"
  ],
  "plugins": ["astro"],
  "settings": {
    "import/parsers": {
      "astro-eslint-parser": [".astro"],
      "espree": [".js"]
    }
  },
  "overrides": [
    {
      "files": ["*.astro"],
      "parser": "astro-eslint-parser",
      "parserOptions": {
        "parser": "@typescript-eslint/parser",
        "extraFileExtensions": [".astro"]
      }
    }
  ]
}
---
import Layout from '../layouts/Layout.astro'
---

<Layout />

What did you expect to happen?

The import of the Astro component should not be highlighted as error

What actually happened?

 2:8  error  No default export found in imported module "../layouts/Layout.astro"    import/default

Link to Minimal Reproducible Example

https://github.com/arty-name/typescript-eslint-astro-fragment

The branch is called export-default

Additional comments

Somehow the error only appeared when the imported component started importing other components.

This is a followup for ota-meshi/eslint-plugin-astro#275

@arty-name
Copy link
Author

Please note, the branch is called export-default

@ota-meshi
Copy link
Owner

Hmm.... I was thinking of returning a virtual export default node from the parser to inform the import plugin of the export default, but that would cause a false positive in another rule.
We should consider another solution 🤔

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

No branches or pull requests

2 participants