Skip to content

Commit 132de5c

Browse files
authored
Merge pull request #430 from sveltejs/disallow-import-root
disallow `import root` during validation
2 parents 7c5eaa2 + f6934a1 commit 132de5c

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/validate/js/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,13 @@ export default function validateJs ( validator, js ) {
6363

6464
validator.defaultExport = node;
6565
}
66+
67+
if ( node.type === 'ImportDeclaration' ) {
68+
node.specifiers.forEach( specifier => {
69+
if ( specifier.local.name === 'root' ) {
70+
validator.error( `Imported identifiers cannot have a name of 'root' due to technical limitations`, specifier.start );
71+
}
72+
});
73+
}
6674
});
6775
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[{
2+
"message": "Imported identifiers cannot have a name of 'root' due to technical limitations",
3+
"pos": 17,
4+
"loc": {
5+
"line": 2,
6+
"column": 8
7+
}
8+
}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
import root from 'foo';
3+
</script>

0 commit comments

Comments
 (0)