Skip to content

Commit 8039de4

Browse files
author
Solomon
committed
fix(rules): skip JSDoc block comments in R-WEB-06 (document.* check)
Add `skip-comments: true` to R-WEB-06 so the `\bdocument\.` pattern is not matched inside JSDoc `/** ... */` block comments or single-line `//` comments. This eliminates a false positive found during field testing of forge: `lib/css/index.js:439` contains `* Parse document.` in a JSDoc block comment, which triggered a blocking FAIL on a vendored CSS parser with no actual DOM API calls. `skip-comments: true` is already supported by `apply-patterns.py` (block-comment state tracking added in a prior commit). No new infrastructure needed — this is a one-line rule configuration change. Test: add JSDoc comment containing `document.` to `web-apis` fixture and assert R-WEB-06 fires exactly once (real call only, not comment). Fixes: forge field test FP (2026-03-22)
1 parent e74c508 commit 8039de4

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

rules/patterns.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
pattern: "\\bdocument\\."
6767
scope: ["*.js"]
6868
severity: blocking
69+
skip-comments: true
6970
message: "DOM APIs (document.*) are not available in GJS"
7071
category: web-apis
7172
fix: "GJS has no DOM. Use GObject/Clutter/St/GTK widgets instead."

tests/fixtures/web-apis/extension.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
22

3+
/**
4+
* Parse document.querySelectorAll results into an array.
5+
* This is a JSDoc comment — document. here must NOT trigger R-WEB-06.
6+
*/
37
export default class WebApisExtension extends Extension {
48
enable() {
59
setTimeout(() => {}, 100);
610
const xhr = new XMLHttpRequest();
7-
document.querySelector('.foo');
11+
document.querySelector('.foo'); // real DOM call — MUST trigger R-WEB-06
812
clearTimeout(this._timer);
913
clearInterval(this._interval);
1014
}

tests/run-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ assert_exit_code "exits with 1 (has failures)" 1
123123
assert_output_contains "fails on setTimeout" "\[FAIL\].*R-WEB-01"
124124
assert_output_contains "fails on XMLHttpRequest" "\[FAIL\].*R-WEB-04"
125125
assert_output_contains "fails on document.*" "\[FAIL\].*R-WEB-06"
126+
assert_output_count "R-WEB-06 fires exactly once (JSDoc comment skipped)" "\[FAIL\].*R-WEB-06" 1
126127
assert_output_contains "fails on clearTimeout" "\[FAIL\].*R-WEB-10"
127128
assert_output_contains "fails on clearInterval" "\[FAIL\].*R-WEB-11"
128129
echo ""

0 commit comments

Comments
 (0)