Skip to content

Commit f170cab

Browse files
marekdedicota-meshi
authored andcommitted
test(valid-style-parse): added tests
1 parent c7155c3 commit f170cab

10 files changed

+112
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Error parsing style element
2+
line: 7
3+
column: 1
4+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="container">
2+
<div class="div-class">Hello</div>
3+
4+
<span class="span-class">World!</span>
5+
</div>
6+
7+
<style>
8+
// This syntax is intentionally invalid CSS - this is to be used to test resiliency against invalid input
9+
.container {
10+
class .div-class/35
11+
# Weird comment
12+
color: red;
13+
14+
.span-class begin
15+
font-weight: bold;
16+
end
17+
}
18+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Error parsing style element
2+
line: 7
3+
column: 1
4+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="container">
2+
<div class="div-class">Hello</div>
3+
4+
<span class="span-class">World!</span>
5+
</div>
6+
7+
<style lang="scss">
8+
// This syntax is intentionally invalid CSS - this is to be used to test resiliency against invalid input
9+
.container {
10+
class .div-class/35
11+
# Weird comment
12+
color: red;
13+
14+
.span-class begin
15+
font-weight: bold;
16+
end
17+
}
18+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: Found unsupported style element language "invalid-lang"
2+
line: 7
3+
column: 1
4+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="container">
2+
<div class="div-class">Hello</div>
3+
4+
<span class="span-class">World!</span>
5+
</div>
6+
7+
<style lang="invalid-lang">
8+
// This syntax is intentionally invalid CSS - this is to be used to test resiliency against unknown style languages.
9+
.container {
10+
class .div-class/35
11+
# Weird comment
12+
color: red;
13+
14+
.span-class begin
15+
font-weight: bold;
16+
end
17+
}
18+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a href="https://svelte.dev">Hello</a>
2+
3+
<span style="font-weight: bold;">World!</span>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="div-class">Hello</div>
2+
3+
<span class="span-class">World!</span>
4+
5+
<style>
6+
.div-class {
7+
color: red;
8+
}
9+
10+
.span-class {
11+
font-weight: bold;
12+
}
13+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="container">
2+
<div class="div-class">Hello</div>
3+
4+
<span class="span-class">World!</span>
5+
</div>
6+
7+
<style lang="scss">
8+
.container {
9+
.div-class {
10+
// This is an inline comment
11+
color: red;
12+
}
13+
14+
.span-class {
15+
font-weight: bold;
16+
}
17+
}
18+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RuleTester } from '../../utils/eslint-compat.js';
2+
import rule from '../../../src/rules/valid-style-parse.js';
3+
import { loadTestCases } from '../../utils/utils.js';
4+
5+
const tester = new RuleTester({
6+
languageOptions: {
7+
ecmaVersion: 2020,
8+
sourceType: 'module'
9+
}
10+
});
11+
12+
tester.run('valid-style-parse', rule as any, loadTestCases('valid-style-parse'));

0 commit comments

Comments
 (0)