mirror of https://github.com/sveltejs/svelte
Merge pull request #3351 from sveltejs/disable-validation
disable validation with magic commentspull/3358/head
commit
57aa46a7fe
@ -1,11 +1,17 @@
|
|||||||
import Node from './shared/Node';
|
import Node from './shared/Node';
|
||||||
|
|
||||||
|
const pattern = /^\s*svelte-ignore\s+([\s\S]+)\s*$/m;
|
||||||
|
|
||||||
export default class Comment extends Node {
|
export default class Comment extends Node {
|
||||||
type: 'Comment';
|
type: 'Comment';
|
||||||
data: string;
|
data: string;
|
||||||
|
ignores: string[];
|
||||||
|
|
||||||
constructor(component, parent, scope, info) {
|
constructor(component, parent, scope, info) {
|
||||||
super(component, parent, scope, info);
|
super(component, parent, scope, info);
|
||||||
this.data = info.data;
|
this.data = info.data;
|
||||||
|
|
||||||
|
const match = pattern.exec(this.data);
|
||||||
|
this.ignores = match ? match[1].split(/[^\S]/).map(x => x.trim()).filter(Boolean) : [];
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
|
<div>
|
||||||
|
<img src="this-is-fine.jpg">
|
||||||
|
<marquee>but this is still discouraged</marquee>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<img src="potato.jpg">
|
@ -0,0 +1,32 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "a11y-distracting-elements",
|
||||||
|
"end": {
|
||||||
|
"character": 131,
|
||||||
|
"column": 49,
|
||||||
|
"line": 4
|
||||||
|
},
|
||||||
|
"message": "A11y: Avoid <marquee> elements",
|
||||||
|
"pos": 83,
|
||||||
|
"start": {
|
||||||
|
"character": 83,
|
||||||
|
"column": 1,
|
||||||
|
"line": 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "a11y-missing-attribute",
|
||||||
|
"end": {
|
||||||
|
"character": 162,
|
||||||
|
"column": 22,
|
||||||
|
"line": 7
|
||||||
|
},
|
||||||
|
"message": "A11y: <img> element should have an alt attribute",
|
||||||
|
"pos": 140,
|
||||||
|
"start": {
|
||||||
|
"character": 140,
|
||||||
|
"column": 0,
|
||||||
|
"line": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,17 @@
|
|||||||
|
<!-- svelte-ignore a11y-structure a11y-missing-attribute -->
|
||||||
|
<div>
|
||||||
|
<figure>
|
||||||
|
<img src="potato.jpg">
|
||||||
|
<marquee>
|
||||||
|
<figcaption>potato</figcaption>
|
||||||
|
</marquee>
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<!-- svelte-ignore a11y-distracting-elements -->
|
||||||
|
<figure>
|
||||||
|
<img src="potato.jpg">
|
||||||
|
<marquee>
|
||||||
|
<figcaption>potato</figcaption>
|
||||||
|
</marquee>
|
||||||
|
</figure>
|
||||||
|
</div>
|
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "a11y-distracting-elements",
|
||||||
|
"end": {
|
||||||
|
"character": 161,
|
||||||
|
"column": 12,
|
||||||
|
"line": 7
|
||||||
|
},
|
||||||
|
"message": "A11y: Avoid <marquee> elements",
|
||||||
|
"pos": 104,
|
||||||
|
"start": {
|
||||||
|
"character": 104,
|
||||||
|
"column": 2,
|
||||||
|
"line": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,8 @@
|
|||||||
|
<!-- svelte-ignore a11y-missing-attribute
|
||||||
|
a11y-distracting-elements -->
|
||||||
|
<div>
|
||||||
|
<img src="this-is-fine.jpg">
|
||||||
|
<marquee>but this is still discouraged</marquee>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<img src="potato.jpg">
|
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "a11y-missing-attribute",
|
||||||
|
"end": {
|
||||||
|
"character": 207,
|
||||||
|
"column": 22,
|
||||||
|
"line": 8
|
||||||
|
},
|
||||||
|
"message": "A11y: <img> element should have an alt attribute",
|
||||||
|
"pos": 185,
|
||||||
|
"start": {
|
||||||
|
"character": 185,
|
||||||
|
"column": 0,
|
||||||
|
"line": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,8 @@
|
|||||||
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
|
<!-- svelte-ignore a11y-distracting-elements -->
|
||||||
|
<div>
|
||||||
|
<img src="this-is-fine.jpg">
|
||||||
|
<marquee>but this is still discouraged</marquee>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<img src="potato.jpg">
|
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "a11y-missing-attribute",
|
||||||
|
"end": {
|
||||||
|
"character": 211,
|
||||||
|
"column": 22,
|
||||||
|
"line": 8
|
||||||
|
},
|
||||||
|
"message": "A11y: <img> element should have an alt attribute",
|
||||||
|
"pos": 189,
|
||||||
|
"start": {
|
||||||
|
"character": 189,
|
||||||
|
"column": 0,
|
||||||
|
"line": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,7 @@
|
|||||||
|
<!-- svelte-ignore a11y-missing-attribute a11y-distracting-elements -->
|
||||||
|
<div>
|
||||||
|
<img src="this-is-fine.jpg">
|
||||||
|
<marquee>but this is still discouraged</marquee>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<img src="potato.jpg">
|
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "a11y-missing-attribute",
|
||||||
|
"end": {
|
||||||
|
"character": 188,
|
||||||
|
"column": 22,
|
||||||
|
"line": 7
|
||||||
|
},
|
||||||
|
"message": "A11y: <img> element should have an alt attribute",
|
||||||
|
"pos": 166,
|
||||||
|
"start": {
|
||||||
|
"character": 166,
|
||||||
|
"column": 0,
|
||||||
|
"line": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in new issue