release: WRNexusJS 0.3.5

This commit is contained in:
2026-07-24 12:46:44 +05:30
parent 44ba847210
commit c81dedff17
2114 changed files with 65790 additions and 150559 deletions
+19 -1
View File
@@ -69,6 +69,7 @@ function parseComponentMetadata(source, uri = null) {
const propsKeyword = /\bprops\s*\{/.exec(source.slice(declaration.index));
const props = [];
const events = [];
if (propsKeyword) {
const start = declaration.index + propsKeyword.index;
const openingBrace = source.indexOf("{", start);
@@ -94,9 +95,12 @@ function parseComponentMetadata(source, uri = null) {
options: inferOptions(source, name),
});
}
const eventPattern = /^\s*@event\s+([A-Za-z_$][\w$]*)\s*=\s*function\s*$/gm;
let eventMatch;
while ((eventMatch = eventPattern.exec(body)) !== null) events.push(eventMatch[1]);
}
return { kind: declaration[1], name: declaration[2], props, uri };
return { kind: declaration[1], name: declaration[2], props, events, uri };
}
function unwrapAttributeValue(value) {
@@ -173,6 +177,7 @@ function validateComponentTags(source, components) {
if (!component) continue;
const provided = new Map(tag.attributes.map((attribute) => [attribute.name, attribute]));
const declared = new Map(component.props.map((prop) => [prop.name, prop]));
const declaredEvents = new Set(component.events || []);
for (const prop of component.props) {
if (prop.required && !provided.has(prop.name)) {
@@ -187,6 +192,19 @@ function validateComponentTags(source, components) {
}
for (const attribute of tag.attributes) {
if (attribute.name.startsWith("@")) {
const eventName = attribute.name.slice(1);
if (!declaredEvents.has(eventName)) {
diagnostics.push({
severity: "warning",
code: "wrn-unknown-component-event",
message: `Unknown event \`${eventName}\` on <${tag.name}>.`,
start: attribute.nameStart,
end: attribute.nameEnd,
});
}
continue;
}
const prop = declared.get(attribute.name);
if (!prop) {
diagnostics.push({