Support for Astro Framework

Greetings,

Astro is a static site generator that allows developers to use web frameworks like Vue or React to build websites.

The astro files look likes this:

---
// Component Script (JavaScript)
---
<!-- Component Template (HTML + JS Expressions) -->

This is similar to markdown format where the area in the top between the dashes --- is called frontmatter. Frontmatter contains the JavaScript/TypeScript code that will be evaluated and executed. The rest is HTML and JS expressions. To work with Astro, there is an extension provided by the team that provides what a developer requires like syntax highlighting, IntelliSense, autocomplete … etc.

By the end of the day, astro component is no different than any React or Vue component. It just follow a different syntax.

The current version of SonarQube does not analyze the .astro files despite adding these files to the extension list of JavaScript.

Astro is becoming extremely popular tool and a lot of organizations are using it. In this thread I am asking to add support for Astro or if anyone can provide me with guidance on the best approach to support this framework. Should it be done as a new plugin or maybe an update needs to be done to the parser?

Thank you

5 Likes

Hi Ahmad,

I know this topic is super old, but I’m tracking interest for Astro, so I added you voice :slight_smile:

Please let me know if there is something particularly interesting you’d like Sonar to detect in Astro code!

Kinds regards,

1 Like

Adding another vote to this, would be quite useful.

Hi Adrian, welcome to the Sonar community!

Thanks for adding your voice for Astro!

Have to tried to analyze an Astro project with Sonar? Did you see any failure? Are there any specific things you’d like Sonar to pick up?

1 Like

Thanks @gab, indeed we tried that recently without success.
I figured adding the .astro extension to the JavaScript file suffixes would do the trick, but no luck.

Is there a setting to make a scan recognize the astro files? As @ahmadalfy put it:

By the end of the day, astro component is no different than any React or Vue component. It just follow a different syntax.

So I would expect Sonar to be able to analyze .astro files as it does with other JS frameworks. I would be fine with a documented workaround such as adding the file extensions to different suffix settings for HTML/JS

The analysis just failed, in any configuration we tried.

EDIT: I just realized this is the SonarQube Server forum – we are using the Cloud product, if that makes a difference at all.

1 Like