lint import from restricted zones for export exressions (#66588)

* line restricted zones for export exressions

* more robust rule

* fix or mute eslint errors

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Mikhail Shustov 2020-05-15 17:21:42 +02:00 committed by GitHub
parent 9df3d9faab
commit 0cc5d133d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 60 additions and 16 deletions

View file

@ -196,6 +196,28 @@ ruleTester.run('@kbn/eslint/no-restricted-paths', rule, {
],
invalid: [
{
code: 'export { b } from "../server/b.js"',
filename: path.join(__dirname, './files/no_restricted_paths/client/a.js'),
options: [
{
basePath: __dirname,
zones: [
{
target: 'files/no_restricted_paths/client/**/*',
from: 'files/no_restricted_paths/server/**/*',
},
],
},
],
errors: [
{
message: 'Unexpected path "../server/b.js" imported in restricted zone.',
line: 1,
column: 19,
},
],
},
{
code: 'import b from "../server/b.js"',
filename: path.join(__dirname, './files/no_restricted_paths/client/a.js'),

View file

@ -126,6 +126,10 @@ module.exports = {
}
return {
ExportNamedDeclaration(node) {
if (!node.source) return;
checkForRestrictedImportPath(node.source.value, node.source);
},
ImportDeclaration(node) {
checkForRestrictedImportPath(node.source.value, node.source);
},