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

Parsing error when linting .astro files #335

Open
martinburger opened this issue Dec 27, 2024 · 2 comments · May be fixed by #320
Open

Parsing error when linting .astro files #335

martinburger opened this issue Dec 27, 2024 · 2 comments · May be fixed by #320
Labels
accepted The issue is accepted and a PR can be proposed. bug Something isn't working

Comments

@martinburger
Copy link

martinburger commented Dec 27, 2024

When I add Sheriff to my Astro project, I get various parsing errors like the following:

/[...]/capricious-chroma/src/components/Welcome.astro
  1:2  error  Parsing error: Expression expected

/[...]/capricious-chroma/src/layouts/Layout.astro
  1:10  error  Parsing error: '>' expected

/[...]/capricious-chroma/src/pages/index.astro
  1:2  error  Parsing error: Expression expected

✖ 3 problems (3 errors, 0 warnings)

To reproduce:

  1. Create a new Astro project by running npm create astro@latest and selecting the default settings:
❯ npm create astro@latest

> npx
> create-astro


 astro   Launch sequence initiated.

   dir   Where should we create your new project?
         ./capricious-chroma

  tmpl   How would you like to start your new project?
         A basic, minimal starter

  deps   Install dependencies?
         Yes

   git   Initialize a new git repository?
         Yes

      ✔  Project initialized!
         ■ Template copied
         ■ Dependencies installed
         ■ Git initialized

  next   Liftoff confirmed. Explore your project!

         Enter your project directory using cd ./capricious-chroma
         Run npm run dev to start the dev server. CTRL+C to stop.
         Add frameworks like react or tailwind using astro add.

         Stuck? Join us at https://astro.build/chat

╭─────╮  Houston:
│ ◠ ◡ ◠  Good luck out there, astronaut! 🚀
╰─────╯
  1. Set up Sheriff by running npm init @sherifforg/config and selecting No for both the experimental eslint.config.ts file and support for Prettier:
❯ npm init @sherifforg/config

> [email protected] npx
> create-config

Welcome to Sheriff! 👋
This wizard will guide you through the setup of Sheriff in your project.
Let's get started!

✔ Do you prefer the config as a Typescript file? The generated config will be a eslint.config.ts file (Experimental)
No
◐ No ESLint config files were found. Generating and configuring eslint.config.js file...

 WARN  If you have other ESLint configs in your project, remove them

◐ 'Astro' package found in the project. Setting up support for it...
ℹ Setting Sheriff with options:

 ╭──────────────────────────────────────────────╮
 │                                              │
 │  {                                           │
 │    "react": false,                           │
 │    "lodash": false,                          │
 │    "remeda": false,                          │
 │    "next": false,                            │
 │    "astro": true,                            │
 │    "playwright": false,                      │
 │    "jest": false,                            │
 │    "vitest": false                           │
 │  }                                           │
 │                                              │
 ╰──────────────────────────────────────────────╯

✔ Successfully generated eslint.config.js file

✔ Do you want to add Prettier support in the workspace?
Tip: if you want to use Prettier from the root of the monorepo, choose 'No'.
No
◐ Installing eslint, eslint-define-config, eslint-config-sheriff...
ℹ Detected package manager: npm
◐ Installing dependendencies...
npm warn ERESOLVE overriding peer dependency
npm warn ERESOLVE overriding peer dependency
npm warn ERESOLVE overriding peer dependency
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported

added 389 packages, and audited 688 packages in 17s

295 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
✔ eslint and eslint-define-config and eslint-config-sheriff were installed successfully
ℹ You're all set! Happy coding 🎉
  1. Run ESLint:
❯ npx eslint .

[see above]

Please note that this issue may be related to ota-meshi/eslint-plugin-astro#447.

@AndreaPontrandolfo
Copy link
Owner

AndreaPontrandolfo commented Dec 27, 2024

I'll look into it. Clearly a parsing issue.

Man, supporting Astro has been a nightmare so far 😂

@AndreaPontrandolfo AndreaPontrandolfo added bug Something isn't working accepted The issue is accepted and a PR can be proposed. labels Dec 27, 2024
@AndreaPontrandolfo
Copy link
Owner

AndreaPontrandolfo commented Jan 5, 2025

I'm thinking it's because we need to adopt this typescript-eslint option: extraFileExtensions.

I'll test this in #320.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue is accepted and a PR can be proposed. bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants