release: WRNexusJS 0.5.10
This commit is contained in:
@@ -31,6 +31,7 @@ const {
|
||||
maskLeadingTrivia,
|
||||
validateBalancedCharacters,
|
||||
validateHtmlTags,
|
||||
validateLayoutUsage,
|
||||
validateRootMembers,
|
||||
} = require("../src/diagnostics");
|
||||
Module._load = originalLoad;
|
||||
@@ -136,6 +137,41 @@ test("ignores member-like words inside component line and block comments", () =>
|
||||
);
|
||||
});
|
||||
|
||||
test("allows a component prop named layout but rejects a root layout member", () => {
|
||||
const component = `component Card {
|
||||
props {
|
||||
layout = "vertical"
|
||||
}
|
||||
view { <article>{layout}</article> }
|
||||
}`;
|
||||
const componentDeclaration = findTopLevelDeclaration({}, component);
|
||||
|
||||
assert.deepEqual(
|
||||
validateLayoutUsage(
|
||||
mockDocument(component),
|
||||
component,
|
||||
componentDeclaration.kind,
|
||||
componentDeclaration.match,
|
||||
),
|
||||
[],
|
||||
);
|
||||
|
||||
const invalid = `component Card {
|
||||
layout = "dashboard"
|
||||
view { <article></article> }
|
||||
}`;
|
||||
const invalidDeclaration = findTopLevelDeclaration({}, invalid);
|
||||
const diagnostics = validateLayoutUsage(
|
||||
mockDocument(invalid),
|
||||
invalid,
|
||||
invalidDeclaration.kind,
|
||||
invalidDeclaration.match,
|
||||
);
|
||||
|
||||
assert.equal(diagnostics.length, 1);
|
||||
assert.equal(diagnostics[0].code, "wrn-invalid-layout-member");
|
||||
});
|
||||
|
||||
test("ignores HTML-like tags inside WRN comments", () => {
|
||||
const source = `// The <section> below listens for child events.
|
||||
// <ComboBox> is only documentation in this comment.
|
||||
|
||||
Reference in New Issue
Block a user