Skip to content

Commit 084275f

Browse files
lint import from restricted zones for export exressions (elastic#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>
1 parent 38f469b commit 084275f

File tree

22 files changed

+60
-16
lines changed

22 files changed

+60
-16
lines changed

packages/kbn-eslint-plugin-eslint/rules/__tests__/no_restricted_paths.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@ ruleTester.run('@kbn/eslint/no-restricted-paths', rule, {
196196
],
197197

198198
invalid: [
199+
{
200+
code: 'export { b } from "../server/b.js"',
201+
filename: path.join(__dirname, './files/no_restricted_paths/client/a.js'),
202+
options: [
203+
{
204+
basePath: __dirname,
205+
zones: [
206+
{
207+
target: 'files/no_restricted_paths/client/**/*',
208+
from: 'files/no_restricted_paths/server/**/*',
209+
},
210+
],
211+
},
212+
],
213+
errors: [
214+
{
215+
message: 'Unexpected path "../server/b.js" imported in restricted zone.',
216+
line: 1,
217+
column: 19,
218+
},
219+
],
220+
},
199221
{
200222
code: 'import b from "../server/b.js"',
201223
filename: path.join(__dirname, './files/no_restricted_paths/client/a.js'),

packages/kbn-eslint-plugin-eslint/rules/no_restricted_paths.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ module.exports = {
126126
}
127127

128128
return {
129+
ExportNamedDeclaration(node) {
130+
if (!node.source) return;
131+
checkForRestrictedImportPath(node.source.value, node.source);
132+
},
129133
ImportDeclaration(node) {
130134
checkForRestrictedImportPath(node.source.value, node.source);
131135
},

src/legacy/core_plugins/kibana/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
export {
2121
ProcessedImportResponse,
2222
processImportResponse,
23-
} from '../../../../plugins/saved_objects_management/public/lib';
23+
} from '../../../../plugins/saved_objects_management/public/lib'; // eslint-disable-line @kbn/eslint/no-restricted-paths

src/legacy/ui/public/private/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
* under the License.
1818
*/
1919

20-
export { IPrivate } from '../../../../plugins/kibana_legacy/public/utils/private';
20+
export { IPrivate } from '../../../../plugins/kibana_legacy/public/';

src/legacy/ui/public/url/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919

2020
export { KbnUrlProvider } from './url';
2121
export { RedirectWhenMissingProvider } from './redirect_when_missing';
22+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
2223
export { modifyUrl } from '../../../../core/utils';

src/legacy/ui/public/visualize/loader/pipeline_helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
* under the License.
1818
*/
1919

20+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
2021
export { buildPipeline } from '../../../../../../plugins/visualizations/public/legacy/build_pipeline';

src/plugins/dashboard/public/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export { DashboardConstants, createDashboardEditUrl } from './dashboard_constant
3333

3434
export { DashboardStart, DashboardUrlGenerator } from './plugin';
3535
export { DASHBOARD_APP_URL_GENERATOR } from './url_generator';
36+
export { addEmbeddableToDashboardUrl } from './url_utils/url_helper';
3637

3738
export function plugin(initializerContext: PluginInitializerContext) {
3839
return new DashboardPlugin(initializerContext);

src/plugins/telemetry_management_section/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
19+
export { OptInExampleFlyout } from './components';
2020
import { TelemetryManagementSectionPlugin } from './plugin';
2121

2222
export function plugin() {

src/plugins/visualize/public/application/editor/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
export { useVisualizeAppState } from './visualize_app_state';
2121
export { makeStateful } from './make_stateful';
22-
export { addEmbeddableToDashboardUrl } from '../../../../../dashboard/public/url_utils/url_helper';
22+
export { addEmbeddableToDashboardUrl } from '../../../../../dashboard/public/';

x-pack/legacy/plugins/maps/public/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export const plugin = () => {
2626
return new MapsPlugin();
2727
};
2828

29-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
3029
export {
3130
RenderTooltipContentParams,
3231
ITooltipProperty,
33-
} from '../../../../plugins/maps/public/classes/tooltips/tooltip_property';
32+
} from '../../../../plugins/maps/public/classes/tooltips/tooltip_property'; // eslint-disable-line @kbn/eslint/no-restricted-paths
33+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
3434
export { MapEmbeddable, MapEmbeddableInput } from '../../../../plugins/maps/public/embeddable';

0 commit comments

Comments
 (0)