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.x] Add consistent-type-imports eslint rule in obs-ux-infra_services-team owned plugins (#204549) #206047

Merged

Conversation

miloszmarcinkowski
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

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/solutions/observability/plugins/apm/public/assistant_functions/get_apm_timeseries.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_duration_rule_type/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_error_rate_rule_type/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/alerting/ui_components/alert_details_app_section/failed_transaction_chart.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/alerting/ui_components/chart_preview/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/correlations/correlations_table.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/entities/entity_link/entity_link.test.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/entities/entity_link/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/error_group_details/distribution/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/error_group_details/error_sampler/sample_summary.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/help_popover/help_popover.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/mobile/service_overview/geo_map/embedded_map.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/mobile/service_overview/geo_map/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_http_requests_map_layer_list.ts
#	x-pack/solutions/observability/plugins/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_layer_list.ts
#	x-pack/solutions/observability/plugins/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_map_layer_style.ts
#	x-pack/solutions/observability/plugins/apm/public/components/app/mobile/service_overview/geo_map/map_layers/get_session_map_layer_list.ts
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_groups/service_groups_list/service_group_card.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_inventory/service_list/health_badge.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/cytoscape.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/cytoscape_options.ts
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/popover/anomaly_detection.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/popover/externals_list_contents.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/popover/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/popover/resource_contents.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_overview/service_overview_instances_table/intance_details.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/top_traces_overview/trace_list.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/accordion_waterfall.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/failure_badge.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/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/span_flyout/truncate_height_section.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/waterfall_item.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/fleet_integration/apm_agents/agent_instructions_accordion.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/routing/app_root/apm_header_action_menu/anomaly_detection_setup_link.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/breakdown_chart/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/duration_distribution_chart/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/instances_latency_distribution_chart/custom_tooltip.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/instances_latency_distribution_chart/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/spark_plot/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/marker/agent_marker.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/marker/error_marker.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/marker/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/timeline_axis.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/vertical_lines.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/links/apm/service_link/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/overview_table_container/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/service_icons/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/stacktrace/context.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/stacktrace/frame_heading.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/stacktrace/library_stacktrace.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/stacktrace/stackframe.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/stacktrace/variables.tsx
#	x-pack/solutions/observability/plugins/apm/public/components/shared/summary/user_agent_summary_item.tsx
#	x-pack/solutions/observability/plugins/apm/public/tutorial/config_agent/index.tsx
#	x-pack/solutions/observability/plugins/apm/public/tutorial/tutorial_fleet_instructions/index.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/plugin.ts
#	x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts
#	x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts
#	x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts
#	x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts
#	x-pack/solutions/observability/plugins/infra/public/alerting/metric_threshold/components/expression_row.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/fixed_datepicker.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/loading_overlay_wrapper.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/log_stream/log_stream_react_embeddable.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/logging/log_analysis_job_status/quality_warning_notices.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/logging/log_entry_examples/log_entry_examples.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/logging/log_minimap/density_chart.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/logging/log_minimap/search_marker.tsx
#	x-pack/solutions/observability/plugins/infra/public/components/logs_deprecation_callout.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_list.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/logs/settings/add_log_column_popover.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/logs/stream/page_logs_content.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/logs/stream/page_view_log_in_context.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/index.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/dropdown_button.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/layout.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/nodes_overview.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/timeline/timeline.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/gradient_legend.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_name.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_groups.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_nodes.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/map.tsx
#	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/pages/metrics/inventory_view/components/waffle/node.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node_context_menu.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node_square.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/stepped_gradient_legend.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/steps_legend.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_sort_controls.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_time_controls.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/metric_detail/components/gauges_section_vis.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/metric_detail/components/metadata_details.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.tsx
#	x-pack/solutions/observability/plugins/infra/public/pages/metrics/metric_detail/types.ts
#	x-pack/solutions/observability/plugins/infra/public/plugin.ts
#	x-pack/solutions/observability/plugins/infra/public/test_utils/entries.ts
#	x-pack/solutions/observability/plugins/infra/public/utils/theme_utils/with_attrs.tsx
#	x-pack/solutions/observability/plugins/infra/server/lib/alerting/common/utils.ts
#	x-pack/solutions/observability/plugins/infra/server/lib/alerting/inventory_metric_threshold/register_inventory_metric_threshold_rule_type.ts
#	x-pack/solutions/observability/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts
#	x-pack/solutions/observability/plugins/metrics_data_access/common/inventory_models/host/metrics/index.ts
#	x-pack/solutions/observability/plugins/profiling/public/components/topn_functions/function_row.tsx
@botelastic botelastic bot added the Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team label Jan 9, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

# Conflicts:
#	x-pack/solutions/observability/plugins/inventory/server/routes/entities/get_group_by_terms_agg.test.ts
#	x-pack/solutions/observability/plugins/inventory/server/routes/entities/get_group_by_terms_agg.ts
#	x-pack/solutions/observability/plugins/inventory/server/routes/entities/get_latest_entities_alerts.ts
#	x-pack/solutions/observability/plugins/inventory/server/routes/entities/route.ts
@rmyz rmyz removed the request for review from kibanamachine January 9, 2025 16:11
@miloszmarcinkowski miloszmarcinkowski merged commit 2ea9fed into elastic:8.x Jan 9, 2025
9 checks passed
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #21 / Templates renders correctly

Metrics [docs]

✅ unchanged

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants