Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.16] Add consistent-type-imports eslint rule in obs-ux-infra_services-team owned plugins (#204549) #206048

Conversation

miloszmarcinkowski
Copy link
Contributor

Backport

This will backport the following commits from main to 8.16:

Questions ?

Please refer to the Backport tool documentation

…eam` owned plugins (elastic#204549)

Closes elastic#204412

## Summary

This PR enforces `consistent-type-imports` eslint rule in
`x-pack/solutions/observability/plugins/*` plugins owned by
`obs-ux-infra_services-team`.

Detailed list of plugins:
- `x-pack/solutions/observability/plugins/apm`,
- `x-pack/solutions/observability/plugins/apm_data_access`,
- `x-pack/solutions/observability/plugins/infra`,
- `x-pack/solutions/observability/plugins/inventory`,
- `x-pack/solutions/observability/plugins/metrics_data_access`,
- `x-pack/solutions/observability/plugins/profiling`,
- `x-pack/solutions/observability/plugins/profiling_data_access`

Script for fixing eslint rules in above plugins:
```bash
yarn eslint --no-error-on-unmatched-pattern --quiet --fix "x-pack/solutions/observability/plugins/apm/**/*.{js,mjs,ts,tsx}" "x-pack/solutions/observability/plugins/apm_data_access/**/*.{js,mjs,ts,tsx}" "x-pack/solutions/observability/plugins/infra/**/*.{js,mjs,ts,tsx}" "x-pack/solutions/observability/plugins/inventory/**/*.{js,mjs,ts,tsx}" "x-pack/solutions/observability/plugins/metrics_data_access/**/*.{js,mjs,ts,tsx}" "x-pack/solutions/observability/plugins/profiling/**/*.{js,mjs,ts,tsx}" "x-pack/solutions/observability/plugins/profiling_data_access/**/*.{js,mjs,ts,tsx}"
```

## Results

The affected plugins have been profiled using `node
scripts/build_kibana_platform_plugins.js --dist --profile --focus=apm
--no-cache` command and bundle size checked manually (`du -s` command).

#### APM plugin
Zero benefits in terms of size.
<img width="1728" alt="Screenshot 2024-12-19 at 12 18 36"
src="https://github.com/user-attachments/assets/d86be5d8-a4ad-4d9c-bac1-110a0c6bba81"
/>

#### Infra plugin
Zero benefits in terms of size.
<img width="1728" alt="Screenshot 2024-12-19 at 12 56 08"
src="https://github.com/user-attachments/assets/410bc068-1f20-4de8-ac4e-89c74478ec59"
/>

#### Profiling plugin
Zero benefits in terms of size.
<img width="1725" alt="image"
src="https://github.com/user-attachments/assets/bf47c319-0716-4a5b-9858-94ce7d2a3251"
/>

## Conclusions

- Using [type-only
imports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
in Kibana doesn't provide any benefits in terms of bundle size,
- Possible safeguarding against edge-case TS errors
- avoiding unintentional side effects
([source](https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how/#avoiding-unintentional-side-effects))
- circular dependency reference error
[(source)](https://stackoverflow.com/questions/40982927/using-import-type-statement-to-fix-circular-dependency-reference-error)
- Better ground for incoming tooling (improving performance, reliability
with type definition analysis),
- Clearer code intent.

(cherry picked from commit 6461b7e)

# Conflicts:
#	x-pack/plugins/observability_solution/apm/public/components/alerting/ui_components/alert_details_app_section/failed_transaction_chart.tsx
#	x-pack/plugins/observability_solution/apm/public/components/alerting/ui_components/chart_preview/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/alerts_overview/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/correlations/correlations_table.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/correlations/use_failed_transactions_correlations.test.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/correlations/use_latency_correlations.test.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/entities/entity_link/entity_link.test.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/entities/entity_link/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/error_group_details/distribution/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/error_group_details/error_sampler/sample_summary.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/help_popover/help_popover.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/infra_overview/infra_tabs/use_tabs.test.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/geo_map/embedded_map.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/geo_map/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_http_requests_map_layer_list.ts
#	x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_layer_list.ts
#	x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_map_layer_style.ts
#	x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_session_map_layer_list.ts
#	x-pack/plugins/observability_solution/apm/public/components/app/service_groups/service_groups_list/service_group_card.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/service_list/health_badge.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_logs/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/cytoscape.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/cytoscape_options.ts
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/popover/anomaly_detection.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/popover/externals_list_contents.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/popover/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_map/popover/resource_contents.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/service_overview/service_overview_instances_table/intance_details.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/top_traces_overview/trace_list.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/accordion_waterfall.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/failure_badge.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/span_flyout/truncate_height_section.tsx
#	x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/waterfall_item.tsx
#	x-pack/plugins/observability_solution/apm/public/components/fleet_integration/apm_agents/agent_instructions_accordion.tsx
#	x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/anomaly_detection_setup_link.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/breakdown_chart/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/duration_distribution_chart/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/instances_latency_distribution_chart/custom_tooltip.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/instances_latency_distribution_chart/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/log_rates/log_error_rate_chart.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/log_rates/log_rate_chart.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/spark_plot/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/timeline/marker/agent_marker.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/timeline/marker/error_marker.test.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/timeline/marker/error_marker.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/timeline/marker/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/timeline/timeline_axis.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/charts/timeline/vertical_lines.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/links/apm/service_link/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/overview_table_container/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/service_icons/index.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/stacktrace/context.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/stacktrace/frame_heading.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/stacktrace/library_stacktrace.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/stacktrace/stackframe.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/stacktrace/variables.tsx
#	x-pack/plugins/observability_solution/apm/public/components/shared/summary/user_agent_summary_item.tsx
#	x-pack/plugins/observability_solution/apm/public/context/apm_plugin/apm_plugin_context.tsx
#	x-pack/plugins/observability_solution/apm/public/hooks/use_breakpoints.test.tsx
#	x-pack/plugins/observability_solution/apm/public/hooks/use_fetcher.test.tsx
#	x-pack/plugins/observability_solution/apm/public/hooks/use_time_range.test.ts
#	x-pack/plugins/observability_solution/apm/public/plugin.ts
#	x-pack/plugins/observability_solution/apm/public/tutorial/config_agent/index.tsx
#	x-pack/plugins/observability_solution/apm/public/tutorial/tutorial_fleet_instructions/index.tsx
#	x-pack/plugins/observability_solution/apm/server/feature.ts
#	x-pack/plugins/observability_solution/apm/server/lib/helpers/get_random_sampler/index.ts
#	x-pack/plugins/observability_solution/apm/server/plugin.ts
#	x-pack/plugins/observability_solution/apm/server/routes/agent_keys/get_agent_keys_privileges.ts
#	x-pack/plugins/observability_solution/apm/server/routes/alerts/register_apm_rule_types.ts
#	x-pack/plugins/observability_solution/apm/server/routes/alerts/test_utils/index.ts
#	x-pack/plugins/observability_solution/apm/server/routes/apm_routes/register_apm_server_routes.ts
#	x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_apm_service_summary/index.ts
#	x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts
#	x-pack/plugins/observability_solution/apm/server/routes/fleet/is_superuser.ts
#	x-pack/plugins/observability_solution/apm/server/routes/service_groups/get_service_group_alerts.ts
#	x-pack/plugins/observability_solution/apm/server/routes/services/get_service_metadata_details.ts
#	x-pack/plugins/observability_solution/apm/server/routes/services/get_services/get_service_transaction_stats.ts
#	x-pack/plugins/observability_solution/apm/server/routes/services/get_services/get_services_without_transactions.ts
#	x-pack/plugins/observability_solution/apm/server/types.ts
#	x-pack/plugins/observability_solution/infra/common/alerting/metrics/types.ts
#	x-pack/plugins/observability_solution/infra/common/constants.ts
#	x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx
#	x-pack/plugins/observability_solution/infra/public/components/asset_details/hooks/use_container_metrics_charts.test.ts
#	x-pack/plugins/observability_solution/infra/public/components/asset_details/hooks/use_container_metrics_charts.ts
#	x-pack/plugins/observability_solution/infra/public/components/asset_details/hooks/use_host_metrics_charts.test.ts
#	x-pack/plugins/observability_solution/infra/public/components/asset_details/hooks/use_host_metrics_charts.ts
#	x-pack/plugins/observability_solution/infra/public/components/autocomplete_field/autocomplete_field.tsx
#	x-pack/plugins/observability_solution/infra/public/components/autocomplete_field/suggestion_item.tsx
#	x-pack/plugins/observability_solution/infra/public/components/fixed_datepicker.tsx
#	x-pack/plugins/observability_solution/infra/public/components/loading_overlay_wrapper.tsx
#	x-pack/plugins/observability_solution/infra/public/components/log_stream/log_stream_react_embeddable.tsx
#	x-pack/plugins/observability_solution/infra/public/components/logging/log_analysis_job_status/quality_warning_notices.tsx
#	x-pack/plugins/observability_solution/infra/public/components/logging/log_entry_examples/log_entry_examples.tsx
#	x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/density_chart.tsx
#	x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/log_minimap.tsx
#	x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/search_marker.tsx
#	x-pack/plugins/observability_solution/infra/public/components/shared/alerts/alerts_overview.tsx
#	x-pack/plugins/observability_solution/infra/public/hooks/use_inventory_views.ts
#	x-pack/plugins/observability_solution/infra/public/hooks/use_lens_attributes.ts
#	x-pack/plugins/observability_solution/infra/public/hooks/use_metrics_explorer_views.ts
#	x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_list.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results_url_state.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/logs/settings/add_log_column_popover.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/logs/stream/page_logs_content.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/logs/stream/page_view_log_in_context.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/hosts/components/search_bar/controls_content.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/hosts/components/tabs/alerts/alerts_tab_content.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/hosts/hooks/use_hosts_table.test.ts
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/index.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/dropdown_button.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/layout.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/nodes_overview.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/table_view.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/timeline/timeline.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/gradient_legend.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/group_name.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/group_of_groups.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/group_of_nodes.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/legend.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/map.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/node.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/node_context_menu.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/node_square.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/stepped_gradient_legend.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/steps_legend.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/waffle_sort_controls.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/waffle_time_controls.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/hooks/use_waffle_filters.test.ts
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/gauges_section_vis.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/metadata_details.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/time_controls.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/types.ts
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx
#	x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options.test.tsx
#	x-pack/plugins/observability_solution/infra/public/plugin.ts
#	x-pack/plugins/observability_solution/infra/public/test_utils/entries.ts
#	x-pack/plugins/observability_solution/infra/server/index.ts
#	x-pack/plugins/observability_solution/infra/server/lib/adapters/framework/adapter_types.ts
#	x-pack/plugins/observability_solution/infra/server/lib/adapters/framework/kibana_framework_adapter.ts
#	x-pack/plugins/observability_solution/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.test.ts
#	x-pack/plugins/observability_solution/infra/server/lib/alerting/inventory_metric_threshold/register_inventory_metric_threshold_rule_type.ts
#	x-pack/plugins/observability_solution/infra/server/lib/alerting/register_rule_types.ts
#	x-pack/plugins/observability_solution/infra/server/plugin.ts
#	x-pack/plugins/observability_solution/infra/server/routes/entities/get_data_stream_types.ts
#	x-pack/plugins/observability_solution/infra/server/routes/infra/lib/host/get_hosts_alerts_count.ts
#	x-pack/plugins/observability_solution/infra/server/services/rules/rules_service.ts
#	x-pack/plugins/observability_solution/infra/server/services/rules/types.ts
#	x-pack/plugins/observability_solution/inventory/.storybook/storybook_decorator.tsx
#	x-pack/plugins/observability_solution/inventory/public/components/app_root/index.tsx
#	x-pack/plugins/observability_solution/inventory/public/components/entities_grid/entities_grid.stories.tsx
#	x-pack/plugins/observability_solution/inventory/public/components/entities_grid/index.tsx
#	x-pack/plugins/observability_solution/inventory/public/context/inventory_search_bar_context_provider/index.tsx
#	x-pack/plugins/observability_solution/inventory/public/services/telemetry/telemetry_service.test.ts
#	x-pack/plugins/observability_solution/inventory/server/lib/create_alerts_client.ts/create_alerts_client.ts
#	x-pack/plugins/observability_solution/inventory/server/routes/entities/get_latest_entities_alerts.ts
#	x-pack/plugins/observability_solution/inventory/server/routes/entities/route.ts
#	x-pack/plugins/observability_solution/metrics_data_access/common/inventory_models/host/metrics/index.ts
#	x-pack/plugins/observability_solution/metrics_data_access/server/lib/adapters/framework/adapter_types.ts
#	x-pack/plugins/observability_solution/profiling/public/components/topn_functions/function_row.tsx
#	x-pack/plugins/observability_solution/profiling/public/types.ts
#	x-pack/plugins/observability_solution/profiling/server/lib/setup/get_has_setup_privileges.ts
#	x-pack/plugins/observability_solution/uptime/e2e/config.ts
#	x-pack/solutions/observability/plugins/apm/public/assistant_functions/get_apm_timeseries.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/responsive_flyout.tsx
#	x-pack/solutions/observability/plugins/apm/server/deprecations/apm_user_role.test.ts
#	x-pack/solutions/observability/plugins/apm/server/deprecations/apm_user_role.ts
#	x-pack/solutions/observability/plugins/apm/server/deprecations/index.ts
#	x-pack/solutions/observability/plugins/apm/server/lib/deprecations/index.ts
#	x-pack/solutions/observability/plugins/apm/server/routes/entities/utils/merge_entities.test.ts
#	x-pack/solutions/observability/plugins/infra/public/components/asset_details/hooks/use_log_charts.ts
#	x-pack/solutions/observability/plugins/infra/public/components/logs_deprecation_callout.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/hosts/components/search_bar/control_panels_config.ts
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/hosts/hooks/use_host_count.test.ts
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/custom_metric_form.tsx
#	x-pack/solutions/observability/plugins/infra/public/utils/theme_utils/with_attrs.tsx
#	x-pack/solutions/observability/plugins/infra/server/config.ts
#	x-pack/solutions/observability/plugins/inventory/e2e/cypress_test_runner.ts
#	x-pack/solutions/observability/plugins/inventory/public/components/entity_group_accordion/mock/inventory_component_wrapper_mock.tsx
#	x-pack/solutions/observability/plugins/inventory/public/components/search_bar/entity_types_multi_select.tsx
#	x-pack/solutions/observability/plugins/inventory/public/utils/group_entity_types_by_status.ts
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants