release: WRNexusJS 0.5.10
This commit is contained in:
@@ -1155,18 +1155,21 @@ function validateRequiredView(document, source, rootKind, rootMatch) {
|
||||
];
|
||||
}
|
||||
|
||||
function validateLayoutUsage(document, source, rootKind) {
|
||||
function validateLayoutUsage(document, source, rootKind, rootMatch) {
|
||||
const diagnostics = [];
|
||||
|
||||
if (rootKind !== "page" && /^\s*layout\s*=/m.test(source)) {
|
||||
const match = /^\s*layout\s*=/m.exec(source);
|
||||
if (rootKind !== "page") {
|
||||
const bodyRange = getRootBodyRange(source, rootMatch);
|
||||
const layoutMember = findRootMembers(source, bodyRange.start, bodyRange.end).find(
|
||||
(member) => member.name === "layout",
|
||||
);
|
||||
|
||||
if (match) {
|
||||
if (layoutMember) {
|
||||
diagnostics.push(
|
||||
createDiagnostic(
|
||||
document,
|
||||
match.index,
|
||||
match.index + match[0].length,
|
||||
layoutMember.start,
|
||||
layoutMember.end,
|
||||
'`layout = "..."` is only valid inside a page.',
|
||||
vscode.DiagnosticSeverity.Error,
|
||||
"wrn-invalid-layout-member",
|
||||
@@ -1229,7 +1232,7 @@ function validateDocument(document) {
|
||||
|
||||
diagnostics.push(...validateRequiredView(document, source, declaration.kind, declaration.match));
|
||||
|
||||
diagnostics.push(...validateLayoutUsage(document, source, declaration.kind));
|
||||
diagnostics.push(...validateLayoutUsage(document, source, declaration.kind, declaration.match));
|
||||
|
||||
return diagnostics;
|
||||
}
|
||||
@@ -1325,6 +1328,7 @@ module.exports = {
|
||||
validateDocument,
|
||||
validateHtmlTags,
|
||||
validateLifecycleBlocks,
|
||||
validateLayoutUsage,
|
||||
validateRootMembers,
|
||||
validateWatchBlocks,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user