Skip to content

Commit a04d72d

Browse files
committed
fix: html and comments parsing
1 parent a26aa1e commit a04d72d

11 files changed

Lines changed: 517 additions & 183 deletions

apps/oxlint/fixtures/astro/debugger.astro

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
// eslint-disable-next-line no-debugger
23
debugger
34
---
45

@@ -16,5 +17,18 @@ debugger
1617
</script>
1718

1819
<script>
20+
// eslint-disable-next-line no-debugger
1921
debugger
2022
</script>
23+
24+
{
25+
/* eslint-disable-next-line no-console */
26+
console.log("suppressed in expression container")
27+
}
28+
29+
<div
30+
id={
31+
// eslint-disable-next-line no-console
32+
console.log("suppressed in attribute")
33+
}
34+
></div>

apps/oxlint/src/lsp/snapshots/fixtures_lsp_frameworks@astro__debugger.astro_vue__debugger.vue_svelte__debugger.svelte_nextjs__[[..rest]]__debugger.ts.snap

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ severity: Some(Warning)
1818
source: Some("oxc")
1919
tags: None
2020

21+
code: "eslint(no-debugger)"
22+
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html"
23+
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"
24+
range: Range { start: Position { line: 10, character: 2 }, end: Position { line: 10, character: 10 } }
25+
related_information[0].message: ""
26+
related_information[0].location.uri: "file://<variable>/fixtures/lsp/frameworks/astro/debugger.astro"
27+
related_information[0].location.range: Range { start: Position { line: 10, character: 2 }, end: Position { line: 10, character: 10 } }
28+
severity: Some(Warning)
29+
source: Some("oxc")
30+
tags: None
31+
32+
code: "eslint(no-debugger)"
33+
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html"
34+
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"
35+
range: Range { start: Position { line: 14, character: 2 }, end: Position { line: 14, character: 10 } }
36+
related_information[0].message: ""
37+
related_information[0].location.uri: "file://<variable>/fixtures/lsp/frameworks/astro/debugger.astro"
38+
related_information[0].location.range: Range { start: Position { line: 14, character: 2 }, end: Position { line: 14, character: 10 } }
39+
severity: Some(Warning)
40+
source: Some("oxc")
41+
tags: None
42+
2143
code: "eslint(no-debugger)"
2244
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html"
2345
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"
@@ -84,6 +106,114 @@ TextEdit: TextEdit {
84106
}
85107

86108

109+
CodeAction:
110+
Title: Remove the debugger statement
111+
Is Preferred: Some(true)
112+
TextEdit: TextEdit {
113+
range: Range {
114+
start: Position {
115+
line: 10,
116+
character: 2,
117+
},
118+
end: Position {
119+
line: 10,
120+
character: 10,
121+
},
122+
},
123+
new_text: "",
124+
}
125+
126+
127+
CodeAction:
128+
Title: Disable no-debugger for this line
129+
Is Preferred: Some(false)
130+
TextEdit: TextEdit {
131+
range: Range {
132+
start: Position {
133+
line: 10,
134+
character: 0,
135+
},
136+
end: Position {
137+
line: 10,
138+
character: 0,
139+
},
140+
},
141+
new_text: " // oxlint-disable-next-line no-debugger\n",
142+
}
143+
144+
145+
CodeAction:
146+
Title: Disable no-debugger for this whole file
147+
Is Preferred: Some(false)
148+
TextEdit: TextEdit {
149+
range: Range {
150+
start: Position {
151+
line: 0,
152+
character: 0,
153+
},
154+
end: Position {
155+
line: 0,
156+
character: 0,
157+
},
158+
},
159+
new_text: "// oxlint-disable no-debugger\n",
160+
}
161+
162+
163+
CodeAction:
164+
Title: Remove the debugger statement
165+
Is Preferred: Some(true)
166+
TextEdit: TextEdit {
167+
range: Range {
168+
start: Position {
169+
line: 14,
170+
character: 2,
171+
},
172+
end: Position {
173+
line: 14,
174+
character: 10,
175+
},
176+
},
177+
new_text: "",
178+
}
179+
180+
181+
CodeAction:
182+
Title: Disable no-debugger for this line
183+
Is Preferred: Some(false)
184+
TextEdit: TextEdit {
185+
range: Range {
186+
start: Position {
187+
line: 14,
188+
character: 0,
189+
},
190+
end: Position {
191+
line: 14,
192+
character: 0,
193+
},
194+
},
195+
new_text: " // oxlint-disable-next-line no-debugger\n",
196+
}
197+
198+
199+
CodeAction:
200+
Title: Disable no-debugger for this whole file
201+
Is Preferred: Some(false)
202+
TextEdit: TextEdit {
203+
range: Range {
204+
start: Position {
205+
line: 0,
206+
character: 0,
207+
},
208+
end: Position {
209+
line: 0,
210+
character: 0,
211+
},
212+
},
213+
new_text: "// oxlint-disable no-debugger\n",
214+
}
215+
216+
87217
CodeAction:
88218
Title: Remove the debugger statement
89219
Is Preferred: Some(true)
@@ -155,6 +285,32 @@ TextEdit: TextEdit {
155285
},
156286
new_text: "",
157287
}
288+
TextEdit: TextEdit {
289+
range: Range {
290+
start: Position {
291+
line: 10,
292+
character: 2,
293+
},
294+
end: Position {
295+
line: 10,
296+
character: 10,
297+
},
298+
},
299+
new_text: "",
300+
}
301+
TextEdit: TextEdit {
302+
range: Range {
303+
start: Position {
304+
line: 14,
305+
character: 2,
306+
},
307+
end: Position {
308+
line: 14,
309+
character: 10,
310+
},
311+
},
312+
new_text: "",
313+
}
158314
TextEdit: TextEdit {
159315
range: Range {
160316
start: Position {

apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ working directory:
77
----------
88

99
! eslint(no-debugger): `debugger` statement is not allowed
10-
,-[fixtures/astro/debugger.astro:2:1]
11-
1 | ---
12-
2 | debugger
13-
: ^^^^^^^^
14-
3 | ---
15-
`----
10+
,-[fixtures/astro/debugger.astro:12:3]
11+
11 | <script asdf >
12+
12 | debugger
13+
: ^^^^^^^^
14+
13 | </script>
15+
`----
1616
help: Remove the debugger statement
1717
1818
! eslint(no-debugger): `debugger` statement is not allowed
19-
,-[fixtures/astro/debugger.astro:19:3]
20-
18 | <script>
21-
19 | debugger
19+
,-[fixtures/astro/debugger.astro:16:3]
20+
15 | <script asdf>
21+
16 | debugger
2222
: ^^^^^^^^
23-
20 | </script>
23+
17 | </script>
2424
`----
2525
help: Remove the debugger statement
2626

27-
Found 4 warnings and 0 errors.
27+
Found 2 warnings and 0 errors.
2828
Finished in <variable>ms on 1 file with 93 rules using 1 threads.
2929
----------
3030
CLI result: LintSucceeded

apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives@oxlint.snap

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -90,51 +90,21 @@ working directory: fixtures/report_unused_directives
9090
`----
9191
help: Remove the debugger statement
9292
93-
! eslint(no-unused-vars): Variable 'unusedVariable2' is declared but never used. Unused variables should start with a '_'.
94-
,-[test.astro:18:7]
95-
17 | // eslint-disable-next-line no-unused-vars
96-
18 | const unusedVariable2 = 100;
97-
: ^^^^^^^|^^^^^^^
98-
: `-- 'unusedVariable2' is declared here
99-
19 |
100-
`----
101-
help: Consider removing this declaration.
102-
103-
! eslint(no-console): Unexpected console statement.
104-
,-[test.astro:22:5]
105-
21 | // eslint-disable-next-line no-console
106-
22 | console.log('Inside test function');
107-
: ^^^^^^^^^^^
108-
23 | }
109-
`----
110-
help: Delete this console statement.
111-
112-
! eslint(no-console): Unexpected console statement.
113-
,-[test.astro:26:1]
114-
25 | // eslint-disable-next-line no-console, no-debugger
115-
26 | console.log('yes'); debugger;
116-
: ^^^^^^^^^^^
117-
27 |
118-
`----
119-
help: Delete this console statement.
120-
121-
! eslint(no-debugger): `debugger` statement is not allowed
122-
,-[test.astro:26:21]
123-
25 | // eslint-disable-next-line no-console, no-debugger
124-
26 | console.log('yes'); debugger;
125-
: ^^^^^^^^^
93+
! Unused eslint-disable directive (no problems were reported from no-debugger).
94+
,-[test.astro:28:41]
12695
27 |
127-
`----
128-
help: Remove the debugger statement
129-
130-
! eslint(no-console): Unexpected console statement.
131-
,-[test.astro:29:1]
13296
28 | // eslint-disable-next-line no-console, no-debugger
97+
: ^^^^^^^^^^^
13398
29 | console.log('no');
134-
: ^^^^^^^^^^^
99+
`----
100+
101+
! Unused eslint-disable directive (no problems were reported).
102+
,-[test.astro:31:3]
135103
30 |
104+
31 | // oxlint-disable-next-line no-debugger, no-for-loop
105+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106+
32 | console.log("complete line");
136107
`----
137-
help: Delete this console statement.
138108
139109
! eslint(no-console): Unexpected console statement.
140110
,-[test.astro:32:1]
@@ -145,6 +115,14 @@ working directory: fixtures/report_unused_directives
145115
`----
146116
help: Delete this console statement.
147117

118+
! Unused eslint-enable directive (no matching eslint-disable directives were found).
119+
,-[test.astro:36:3]
120+
35 |
121+
36 | // eslint-enable
122+
: ^^^^^^^^^^^^^^
123+
37 | </script>
124+
`----
125+
148126
! Unused eslint-disable directive (no problems were reported).
149127
,-[test.js:4:3]
150128
3 |
@@ -334,7 +312,7 @@ working directory: fixtures/report_unused_directives
334312
37 | </script>
335313
`----
336314

337-
Found 38 warnings and 0 errors.
315+
Found 37 warnings and 0 errors.
338316
Finished in <variable>ms on 5 files with 94 rules using 1 threads.
339317
----------
340318
CLI result: LintSucceeded

0 commit comments

Comments
 (0)