Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/add-astro-framework-detection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"oxlint-plugin-react-doctor": patch
"@react-doctor/core": patch
"react-doctor": patch
---

feat: add Astro framework detection

Astro projects are now correctly detected as `framework: "astro"` instead of `"unknown"`. Astro is checked before Vite in the detection order since Astro projects typically depend on both `astro` and `vite` packages, and the more specific framework should take precedence.

This change also adds `.astro` file extension to the lintable source file pattern, though full rule support for Astro template syntax is not yet complete.
2 changes: 1 addition & 1 deletion packages/core/src/project-info/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const HTML_FILE_PATTERN = /\.html$/i;
export const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
export const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|astro|[hH][tT][mM][lL])$/;

// Bundler output — IIFE / UMD / global builds and explicitly-minified
// drops (e.g. tsup/rollup emitting `widget.iife.js`, `sdk.umd.js`,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/project-info/detectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const FRAMEWORK_PACKAGES: Record<string, Framework> = {
"@tanstack/react-start": "tanstack-start",
"@remix-run/react": "remix",
gatsby: "gatsby",
astro: "astro",
vite: "vite",
"react-scripts": "cra",
expo: "expo",
Expand All @@ -241,6 +242,7 @@ const FRAMEWORK_DISPLAY_NAMES: Record<Framework, string> = {
cra: "Create React App",
remix: "Remix",
gatsby: "Gatsby",
astro: "Astro",
expo: "Expo",
"react-native": "React Native",
preact: "Preact",
Expand Down
19 changes: 18 additions & 1 deletion packages/core/tests/discover-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@react-doctor/core";

const FIXTURES_DIRECTORY = path.resolve(import.meta.dirname, "fixtures");
const VALID_FRAMEWORKS = ["nextjs", "vite", "cra", "remix", "gatsby", "unknown"];
const VALID_FRAMEWORKS = ["nextjs", "vite", "cra", "remix", "gatsby", "astro", "unknown"];

interface ReactCompilerDetectionCase {
readonly name: string;
Expand Down Expand Up @@ -2824,6 +2824,22 @@ describe("listWorkspacePackages", () => {
expect(projectInfo.framework, "the framework package outranks its bundler").toBe("gatsby");
});

it("classifies an Astro app that also lists Vite as `astro`, not `vite`", () => {
const projectDirectory = path.join(tempDirectory, "astro-with-vite");
fs.mkdirSync(projectDirectory, { recursive: true });
fs.writeFileSync(
path.join(projectDirectory, "package.json"),
JSON.stringify({
name: "astro-with-vite",
dependencies: { astro: "^7.1.5", react: "^19.2.8" },
devDependencies: { vite: "^6.0.0" },
}),
);

const projectInfo = discoverProject(projectDirectory);
expect(projectInfo.framework, "the framework package outranks its bundler").toBe("astro");
});

it("flags a web-rooted monorepo with an Expo workspace as an Expo project", () => {
const rootDirectory = path.join(tempDirectory, "expo-workspace-monorepo");
const mobileDirectory = path.join(rootDirectory, "apps", "mobile");
Expand Down Expand Up @@ -4451,6 +4467,7 @@ describe("formatFrameworkName", () => {
expect(formatFrameworkName("cra")).toBe("Create React App");
expect(formatFrameworkName("remix")).toBe("Remix");
expect(formatFrameworkName("gatsby")).toBe("Gatsby");
expect(formatFrameworkName("astro")).toBe("Astro");
});

it("formats unknown framework as React", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const FRAMEWORK_TOKENS = [
"cra",
"remix",
"gatsby",
"astro",
"expo",
"react-native",
"tanstack-start",
Expand Down
Loading