Skip to content

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

@arty-name

Description

@arty-name

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions