warn only for imported variable

pull/5302/head
Tan Li Hau 5 years ago
parent 1f44aa5787
commit 93420d8ab0

@ -628,11 +628,13 @@ export default class Component {
}
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
const imported = node.type.startsWith('Import');
this.add_var({
name,
initialised: instance_scope.initialised_declarations.has(name),
writable
writable,
imported
});
this.node_for_declaration.set(name, node);

@ -184,7 +184,7 @@ export default class Element extends Node {
case 'Attribute':
case 'Spread':
// special case
// special case
if (node.name === 'xmlns') this.namespace = node.value[0].data;
this.attributes.push(new Attribute(component, this, scope, node));
@ -239,10 +239,10 @@ export default class Element extends Node {
}
validate() {
if (this.component.var_lookup.has(this.name) || this.scope.names.has(this.name)) {
if (this.component.var_lookup.has(this.name) && this.component.var_lookup.get(this.name).imported) {
this.component.warn(this, {
code: 'lowercase-component-name',
message: `A lowercase tag <${this.name}> will be treated as a regular HTML element`,
message: `A lowercase tag <${this.name}> will be treated as a regular HTML element`
});
}

@ -161,6 +161,7 @@ export interface Var {
hoistable?: boolean;
subscribable?: boolean;
is_reactive_dependency?: boolean;
imported?: boolean;
}
export interface CssResult {

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

@ -1,17 +0,0 @@
[
{
"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
}
}
]

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

@ -2,16 +2,16 @@
{
"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
},
"pos": 84,
"start": {
"character": 75,
"character": 84,
"column": 0,
"line": 5
"line": 6
},
"end": {
"character": 104,
"column": 20,
"line": 6
}
}
]

Loading…
Cancel
Save