0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 01:11:24 +01:00

Merge pull request #430 from sveltejs/disallow-import-root

disallow `import root` during validation
This commit is contained in:
Rich Harris 2017-04-02 08:35:44 -04:00 committed by GitHub
commit 132de5cf72
3 changed files with 19 additions and 0 deletions

View File

@ -63,5 +63,13 @@ export default function validateJs ( validator, js ) {
validator.defaultExport = node;
}
if ( node.type === 'ImportDeclaration' ) {
node.specifiers.forEach( specifier => {
if ( specifier.local.name === 'root' ) {
validator.error( `Imported identifiers cannot have a name of 'root' due to technical limitations`, specifier.start );
}
});
}
});
}

View File

@ -0,0 +1,8 @@
[{
"message": "Imported identifiers cannot have a name of 'root' due to technical limitations",
"pos": 17,
"loc": {
"line": 2,
"column": 8
}
}]

View File

@ -0,0 +1,3 @@
<script>
import root from 'foo';
</script>