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:
commit
132de5cf72
@ -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 );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
8
test/validator/samples/import-root/errors.json
Normal file
8
test/validator/samples/import-root/errors.json
Normal 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
|
||||
}
|
||||
}]
|
3
test/validator/samples/import-root/input.html
Normal file
3
test/validator/samples/import-root/input.html
Normal file
@ -0,0 +1,3 @@
|
||||
<script>
|
||||
import root from 'foo';
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user