warn for possible misname component to lowercase

pull/5302/head
Tan Li Hau 5 years ago
parent 0d75daa1b0
commit 1f44aa5787

@ -239,6 +239,13 @@ export default class Element extends Node {
} }
validate() { validate() {
if (this.component.var_lookup.has(this.name) || this.scope.names.has(this.name)) {
this.component.warn(this, {
code: 'lowercase-component-name',
message: `A lowercase tag <${this.name}> will be treated as a regular HTML element`,
});
}
if (a11y_distracting_elements.has(this.name)) { if (a11y_distracting_elements.has(this.name)) {
// no-distracting-elements // no-distracting-elements
this.component.warn(this, { this.component.warn(this, {

@ -0,0 +1,6 @@
<script>
let array;
</script>
{#each array as item}
<item />
{/each}

@ -0,0 +1,17 @@
[
{
"code": "lowercase-component-name",
"end": {
"character": 64,
"column": 10,
"line": 5
},
"message": "A lowercase tag <item> will be treated as a regular HTML element",
"pos": 56,
"start": {
"character": 56,
"column": 2,
"line": 5
}
}
]

@ -0,0 +1,5 @@
<script>
import thisShouldWarnMe from './MyComponent.svelte';
</script>
<thisShouldWarnMe />

@ -0,0 +1,17 @@
[
{
"code": "lowercase-component-name",
"message": "A lowercase tag <thisShouldWarnMe> will be treated as a regular HTML element",
"pos": 75,
"end": {
"character": 95,
"column": 20,
"line": 5
},
"start": {
"character": 75,
"column": 0,
"line": 5
}
}
]
Loading…
Cancel
Save