Skip to content

Commit b678b8d

Browse files
committed
test: add QML case
Signed-off-by: Joseph Kato <joseph@jdkato.io>
1 parent e82432d commit b678b8d

2 files changed

Lines changed: 134 additions & 8 deletions

File tree

‎testdata/e2e/lint.yaml‎

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ cases:
379379
380380
- name: qml-fragments
381381
about: doc comments in QML sources lint as QDoc through `[formats]`;
382-
the QML code itself is never prose
382+
the QML code itself -- objects, bindings, functions, strings, line
383+
comments, and snippet markers -- is never prose
383384
files:
384385
.vale.ini: |
385386
StylesPath = styles
@@ -390,31 +391,71 @@ cases:
390391
391392
[*.qml]
392393
T.Tok = YES
394+
T.Note = YES
393395
styles/T/Tok.yml: |
394396
extends: existence
395397
message: "'%s' in a doc comment"
396398
level: error
397399
nonword: true
398400
raw:
399401
- ZQX
400-
Button.qml: |
402+
styles/T/Note.yml: |
403+
extends: existence
404+
message: "'%s' in a note"
405+
scope: class.note
406+
level: error
407+
nonword: true
408+
tokens:
409+
- ZQX
410+
Slider.qml: |
401411
import QtQuick
402412
403413
/*!
404-
\qmltype Button
414+
\qmltype Slider
415+
\inqmlmodule Custom.Controls
405416
\brief A ZQX in the brief.
406417
418+
A ZQX in body prose. Another sentence follows it.
419+
407420
\section1 A ZQX heading
421+
422+
\code
423+
Slider { value: ZQX }
424+
\endcode
425+
426+
\note A ZQX in a note.
408427
*/
409-
Button {
428+
Item {
429+
id: root
430+
431+
//! [0]
410432
// A ZQX in a line comment stays code.
411-
width: ZQX
433+
property real value: 0 // a trailing ZQX comment is code too
434+
//! [0]
435+
436+
/*
437+
A ZQX in a plain block comment still lints.
438+
*/
439+
function formatValue(v) {
440+
var label = "a ZQX in a string is code";
441+
return label + v;
442+
}
443+
444+
/*!
445+
\qmlproperty real Slider::value
446+
A second block: its ZQX follows a topic line.
447+
*/
412448
}
413-
args: Button.qml
449+
args: Slider.qml
414450
exit: 1
415451
want: |
416-
Button.qml:5:14:T.Tok:'ZQX' in a doc comment
417-
Button.qml:7:17:T.Tok:'ZQX' in a doc comment
452+
Slider.qml:6:14:T.Tok:'ZQX' in a doc comment
453+
Slider.qml:8:7:T.Tok:'ZQX' in a doc comment
454+
Slider.qml:10:17:T.Tok:'ZQX' in a doc comment
455+
Slider.qml:16:13:T.Note:'ZQX' in a note
456+
Slider.qml:16:13:T.Tok:'ZQX' in a doc comment
457+
Slider.qml:27:11:T.Tok:'ZQX' in a doc comment
458+
Slider.qml:36:29:T.Tok:'ZQX' in a doc comment
418459
419460
- name: quarto
420461
about: "#793 -- fenced divs, attributes, and shortcodes are markup, div
@@ -561,6 +602,18 @@ cases:
561602
test.rs:7:4:vale.Annotations:'FIXME' left in text
562603
test.rs:9:5:vale.Annotations:'XXX' left in text
563604
605+
- name: qml
606+
args: test.qml
607+
exit: 0
608+
want: |
609+
test.qml:1:4:vale.Annotations:'NOTE' left in text
610+
test.qml:9:4:vale.Annotations:'XXX' left in text
611+
test.qml:17:8:vale.Annotations:'TODO' left in text
612+
test.qml:23:33:vale.Annotations:'TODO' left in text
613+
test.qml:41:16:vale.Annotations:'XXX' left in text
614+
absent:
615+
- FIXME
616+
564617
- name: r
565618
args: test.r
566619
exit: 0

‎testdata/fixtures/formats/test.qml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// NOTE: this control is part of the internal design system.
2+
// Copyright (C) 2026 Example Ltd.
3+
4+
import QtQuick 2.15
5+
import QtQuick.Controls 2.15
6+
import QtQuick.Layouts 1.15
7+
8+
/*
9+
XXX: the hover animation still stutters on embedded targets;
10+
see the upstream discussion before changing the duration.
11+
*/
12+
Rectangle {
13+
id: root
14+
15+
/**
16+
* Emitted after the busy indicator finishes hiding.
17+
* TODO: pass the reason for the state change along.
18+
*/
19+
signal settled(string reason)
20+
21+
property alias label: caption.text
22+
property bool busy: false
23+
property int padding: 12 // TODO: read this from the active theme
24+
25+
width: caption.implicitWidth + padding * 2
26+
height: caption.implicitHeight + padding * 2
27+
radius: 4
28+
color: mouse.pressed ? "#c0c0c0" : "#e0e0e0"
29+
30+
Text {
31+
id: caption
32+
text: "FIXME is ignored inside a string"
33+
anchors.centerIn: parent
34+
}
35+
36+
MouseArea {
37+
id: mouse
38+
anchors.fill: parent
39+
hoverEnabled: true
40+
onClicked: {
41+
// XXX: double-tap also lands here on touch screens.
42+
if (root.busy)
43+
return;
44+
root.state = "busy";
45+
}
46+
}
47+
48+
BusyIndicator {
49+
id: spinner
50+
anchors.centerIn: parent
51+
running: root.busy
52+
visible: running
53+
}
54+
55+
states: [
56+
State {
57+
name: "busy"
58+
PropertyChanges { target: root; busy: true }
59+
}
60+
]
61+
62+
transitions: [
63+
Transition {
64+
from: "busy"; to: ""
65+
NumberAnimation { properties: "opacity"; duration: 150 }
66+
}
67+
]
68+
69+
function describe() {
70+
var parts = ["FIXME markers in code are not prose"];
71+
return parts.join(", ");
72+
}
73+
}

0 commit comments

Comments
 (0)