Skip to content
Open
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
31 changes: 31 additions & 0 deletions src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import {
shouldWarnForDefaultSupabaseConfig,
} from '../utils/defaultStorageConfig';

const modules = import.meta.glob(
[
'../public/**/*.{mjs,js,mts,ts,jsx,tsx}',
'!../public/**/*.spec.{mjs,js,mts,ts,jsx,tsx}',
],
{ eager: false }, // the parser only checks if the path exists
);

const ajv1 = new Ajv({ allowUnionTypes: true });
ajv1.addSchema(globalSchema);
const globalValidate = ajv1.getSchema<GlobalConfig>('#/definitions/GlobalConfig')!;
Expand Down Expand Up @@ -311,6 +319,29 @@ function verifyStudyConfig(studyConfig: StudyConfig, importedLibrariesData: Reco
});
});

// Verify that paths to React components exist under the correct base directory
if (studyConfig.baseComponents != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseComponents is optional, so this guard skips validation of the required components object whenever a study does not define any base components. A direct React component with a missing path therefore receives no error. Please remove the outer guard and always iterate both collections using studyConfig[key] ?? {}.

for (const key of ['baseComponents', 'components'] as const) {
for (const [name, component] of Object.entries(studyConfig[key] ?? {})) {
if (
'path' in component
&& component.path != null
&& component.type === 'react-component'

@JackWilb JackWilb Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks the raw component rather than its resolved inherited shape. A child can inherit type: react-component from its base component while overriding path; because component.type is then undefined here, an unresolved override passes validation. Please merge the referenced base component with the child before checking the effective type and path, as the existing sidebar validation does.

&& !(`../public/${component.path}` in modules)
) {
errors.push({
message: 'Unresolved path',
instancePath: `/${key}/${name}/path`,
params: {
action: 'Make sure the React component is in `src/public/`, not `public/`',
},
category: 'undefined-component',
});
}
}
}
}

return { errors, warnings };
}

Expand Down