mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
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:
parent
9df3d9faab
commit
0cc5d133d9
22 changed files with 60 additions and 16 deletions
|
@ -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'),
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue