opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.7k stars 898 forks source link

[Proposal] replace lodash methods and other usage to native built-in JavaScript methods #3661

Open ananzh opened 1 year ago

ananzh commented 1 year ago

Based on usage research issue (https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3660) regarding the methods, the goal of this task:

ltwmori commented 1 year ago

I've created a migration plan, but I'm not entirely certain about its accuracy. Would you mind taking a look and providing feedback?

Plan:

Step 1: Analyze and catalog Lodash usage

  1. Identify all instances of Lodash functions used in the codebase.
  2. Create a spreadsheet or document listing the functions, their usage count, and the files they are used in.

Step 2: Research and propose native JavaScript alternatives

  1. For each Lodash function, find one or more native JavaScript alternatives.
  2. Document the pros and cons of each alternative, considering factors such as performance, browser compatibility, and readability.

Step 3: Prioritize Lodash functions for replacement

  1. Rank the Lodash functions based on factors like usage frequency and potential performance gains.
  2. Create a priority list to guide the replacement process.

Step 4: Divide the project into logical sections

  1. Break down the project into smaller, manageable sections based on functionality or components (e.g., core functionality, utility functions, UI components).
  2. Assign specific Lodash functions to each section to facilitate replacement.

Step 5: Create sub-tasks for each section and Lodash function

  1. For each section, create sub-tasks that focus on replacing individual Lodash functions.
  2. Estimate the effort required for each sub-task to help with planning and resource allocation.

Step 6: Implement native JavaScript alternatives

  1. Starting with the highest priority sub-tasks, replace Lodash functions with the chosen native JavaScript alternatives.
  2. Ensure that the new implementations maintain the same functionality and behavior as the original Lodash functions.

Step 7: Update and run tests

  1. Modify existing test cases to accommodate the new native JavaScript methods.
  2. Add new test cases as needed to ensure comprehensive test coverage
  3. Run tests after each replacement to ensure that the codebase remains stable and functional.

Step 8: Review and optimize

  1. Conduct code reviews to verify that the replacements have been implemented correctly and follow best practices.
  2. Optimize the new implementations to maximize performance and maintainability.
ananzh commented 1 year ago

Rank the Lodash functions based on factors like usage frequency and potential performance gains. Create a priority list to guide the replacement process.


It is hard to give a rank. We could just move to step 4 and start working on them one by one. 

* Step 4 and 5 could be combined. Just need to break down to small sub issues. 
* Step 6, 7 and 8 are all implementation details. 

Overall we could focus on 1) summarize usage in https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3660  2) propose solutions with pros and cons 3) break down tasks into sub issues.

@ltwmori Are you interested in taking this task? 
nurSaadat commented 1 year ago

Hello @ananzh ! Yes, I'd like to collaborate on this issue as well.

ltwmori commented 1 year ago

Hi, I already have an issue to work on. So, mb @nurSaadat can work on it?

Aigerim-ai commented 1 year ago

@nurSaadat Let's work together?

Aigerim-ai commented 1 year ago

Based on the issue at https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3660, let's summarize the key points. Here are a couple of questions that summarize the issue as well as migration plan:

Do we really need to eliminate Lodash entirely from our project? Some functions cannot be replaced with native JS, so we do need Lodash in some cases, such as cloneDeep. However, we should import only the necessary functions instead of using the entire library. For example, we can import cloneDeep from "lodash/cloneDeep" and install npm i lodash.clonedeep --save, rather than installing the whole package.

What is the difference between Lodash and Underscore.js? Lodash API is a superset of Underscore.js. Lodash tends to prioritize performance and provides many optimized methods, while Underscore.js focuses more on simplicity and ease of use. We need to decide whether performance or ease of use is more important. If performance is a top concern, we may want to consider using Lodash. However, if simplicity and ease of use are more important, Underscore.js may be the better choice.

Are we replacing Lodash with ES6 or ES5? We should use both since we have already encountered legacy codebases dependent on ES5. I found a useful plugin (https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore) that can help identify places in the codebase where we don't need Lodash or Underscore. We can install this plugin to reduce mundane work, but we should also consider creating our own plugin.

To replace Lodash functions with native JavaScript methods, we can follow these steps:

Step 1: If we use the Eslint plugin (https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore), we can install the plugin from npm, replace all files by Eslint suggestion, and look for cases where we are not replacing our functionality. Step 2: Consider whether to use ES6 or ES5. Replace the most commonly used methods first, then replace functions by type (e.g., replace all Arrays, then Collections, etc.). Rewrite testing files and test. Step 3: Replace with importing only the necessary methods, not the whole package. Remove all unnecessary imports without usages. If we are not using the Eslint plugin, replace all Lodash functions replaceable by category (Array, Collection, Lang, Functions, etc.) according to the table. Replace the most popular category first. For irreplaceable methods, brush up the usage by installing only the particular method used.

References https://nicozerpa.com/lodash-underscore-necessary-or-obsolete/ https://www.geeksforgeeks.org/difference-between-lodash-and-underscore/

Aigerim-ai commented 1 year ago

I need to fill up this table entirely as pre-step for replacement, I am free for helping me:

method Method type Any issues with this method Can be replaced with native JS Count of occurrence Additional notes ES6 or ES 5? Occurrences in files
_.cloneDeepWith( value, customizer ) Lang   No 4     OpenSearch-Dashboards/test/functional/services/common/browser.tsDeep_clone_with_buffers.jspackages/osd-test/src/functional_test_runner/lib/config/config.tspackages/osd-pm/src/test_helpers/absolute_path_snapshot_serializer.ts
_.keyBy( collection, iteratee ) Collection   yes 3     OpenSearch-Dashboards/test/functional/page_objects/management/saved_objects_page.tsOpenSearch-Dashboards/test/functional/apps/management/_import_objects.js
_.remove(array, function) Array https://dustinpfister.github.io/2017/09/19/lodash_remove/ Yes   We need to chose one: I will be going over vanilla js solutions for removing elements from an array.native array filter, array slice, Array.splice to remove a element   OpenSearch-Dashboards/test/functional/apps/visualize/_chart_types.ts
_.get(object, path, [defaultValue]) Object No Yes >40     OpenSearch-Dashboards/test/common/services/deployment.tsOpenSearch-Dashboards/test/api_integration/apis/dql_telemetry/dql_telemetry.jsOpenSearch-Dashboards/src/plugins/visualize/public/application/utils/migrate_app_state.tsOpenSearch-Dashboards/src/plugins/visualizations/server/saved_objects/visualization_migrations.tsOpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.tsOpenSearch-Dashboards/src/plugins/visualizations/public/legacy/vis_update_state.jsOpenSearch-Dashboards/src/plugins/visualizations/public/legacy/build_pipeline.tsOpenSearch-Dashboards/src/plugins/visualizations/public/expressions/visualization_function.tsOpenSearch-Dashboards/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsOpenSearch-Dashboards/src/plugins/visualizations/public/components/visualization.tsx
.uniq(array).map( collection, iteratee )             OpenSearch-Dashboards/test/api_integration/apis/telemetry/telemetry_local.js
_.set(object, path, value) -> @elastic/safer-lodash-set             OpenSearch-Dashboards/test/api_integration/apis/saved_objects/migrations.tsOpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.tsOpenSearch-Dashboards/src/plugins/visualizations/public/legacy/vis_update_state.js
_.omit( object, paths )             OpenSearch-Dashboards/test/api_integration/apis/saved_objects/migrations.tsOpenSearch-Dashboards/test/api_integration/apis/saved_objects/bulk_update.jsOpenSearch-Dashboards/src/plugins/visualize/public/application/utils/migrate_app_state.tsOpenSearch-Dashboards/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts
_.sortBy(collection, iteratees)             OpenSearch-Dashboards/test/api_integration/apis/saved_objects/bulk_update.jsOpenSearch-Dashboards/packages/osd-ui-framework/src/services/sort/sortable_properties.js
_.isNull(value)             OpenSearch-Dashboards/tasks/licenses_csv_report.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.js
_.isUndefined(value)             OpenSearch-Dashboards/tasks/licenses_csv_report.jsOpenSearch-Dashboards/src/plugins/visualizations/public/expressions/vis.ts
_.assign( dest_object, src_obj )             OpenSearch-Dashboards/src/test_utils/get_url.js
_.pickBy( object, predicate )             OpenSearch-Dashboards/src/test_utils/get_url.js
_.pick( object, paths )             OpenSearch-Dashboards/src/test_utils/get_url.js
_.template( string, options )             OpenSearch-Dashboards/src/setup_node_env/harden/lodash_template.js
_.cloneDeep( value )             OpenSearch-Dashboards/src/plugins/visualize/public/application/utils/use/use_visualize_app_state.tsxOpenSearch-Dashboards/src/plugins/visualize/public/application/utils/get_visualization_instance.tsOpenSearch-Dashboards/src/plugins/visualizations/server/saved_objects/visualization_migrations.tsOpenSearch-Dashboards/src/plugins/visualizations/public/legacy/vis_update_state.test.jsOpenSearch-Dashboards/src/plugins/visualizations/public/vis_types/react_vis_type.test.tsOpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.tsOpenSearch-Dashboards/src/plugins/visualizations/public/legacy/vis_update_state.jsOpenSearch-Dashboards/src/plugins/visualizations/public/expressions/vis.tsOpenSearch-Dashboards/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsOpenSearch-Dashboards/src/plugins/visualizations/public/vis.ts
_.isEqual( value1, value2)             OpenSearch-Dashboards/src/plugins/visualize/public/application/utils/use/use_visualize_app_state.tsxOpenSearch-Dashboards/src/plugins/visualize/public/application/utils/use/use_editor_updates.tsOpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.tsOpenSearch-Dashboards/src/plugins/visualizations/public/legacy/vis_update_state.test.jsOpenSearch-Dashboards/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts
_.has(object, path)             OpenSearch-Dashboards/src/plugins/visualize/public/application/utils/migrate_legacy_query.tsOpenSearch-Dashboards/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts
_.isFunction( value )             OpenSearch-Dashboards/src/plugins/visualize/public/application/utils/create_visualize_app_state.tsOpenSearch-Dashboards/src/plugins/visualizations/public/expressions/vis.tsOpenSearch-Dashboards/src/plugins/visualizations/public/vis.tsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js
_.omitBy( object, predicate )             OpenSearch-Dashboards/src/plugins/visualize/public/application/utils/create_visualize_app_state.ts
_.union(*arrays)             OpenSearch-Dashboards/src/plugins/visualize/public/application/utils/create_visualize_app_state.ts
.countBy(collection, [iteratee=.identity])             OpenSearch-Dashboards/src/plugins/visualizations/server/usage_collector/get_usage_collector.ts
_.groupBy( collection, iteratee )             OpenSearch-Dashboards/src/plugins/visualizations/server/usage_collector/get_usage_collector.ts
_.mapValues( object, iteratee )             OpenSearch-Dashboards/src/plugins/visualizations/server/usage_collector/get_usage_collector.ts
_.max             OpenSearch-Dashboards/src/plugins/visualizations/server/usage_collector/get_usage_collector.ts
_.min             OpenSearch-Dashboards/src/plugins/visualizations/server/usage_collector/get_usage_collector.tsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.js
_.value             OpenSearch-Dashboards/src/plugins/visualizations/server/usage_collector/get_usage_collector.ts
_.flow( funcs )             OpenSearch-Dashboards/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts
_.orderBy(collection, iteratees, orders)             OpenSearch-Dashboards/src/plugins/visualizations/public/wizard/type_selection/type_selection.tsx
_.defaultsDeep(object, [sources])             OpenSearch-Dashboards/src/plugins/visualizations/public/vis_types/base_vis_type.tsOpenSearch-Dashboards/src/plugins/visualizations/public/expressions/vis.tsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js
_.isPlainObject             OpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.ts
_.isString             OpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.ts
_.merge             OpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.ts
_.mergeWith             OpenSearch-Dashboards/src/plugins/visualizations/public/persisted_state/persisted_state.ts
_.defaults             OpenSearch-Dashboards/src/plugins/visualizations/public/vis.tsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/_point_series.js
_.noop             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js
_.find             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/_point_series.jsOpenSearch-Dashboards/src/cli/cli.js
_.isNumber             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.jsOpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js
_.forOwn             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js
_.last             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
_.isObject             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/vis_types.test.jsOpenSearch-Dashboards/packages/osd-ui-framework/src/components/table/listing_table/listing_table_row.jsOpenSearch-Dashboards/packages/osd-ui-framework/src/components/table/listing_table/listing_table.js
_.uniqueId             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series.js
_.identity             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series.js
_.each             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series.js
_.bind             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/visualizations/_chart.js
_.forEach              
_.flattenDeep             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/axis/y_axis.test.js
_.isDate             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/axis/x_axis.test.js
_.times             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_scale.js
_.reduce             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_scale.js
_.isNaN             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_scale.js
_.filter             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/handler.js
_.memoize             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/handler.js
_.first             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.test.js
_.pull             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.js
_.rest             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.js
_.size             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.jsOpenSearch-Dashboards/src/cli/help.js
_.reduce             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.js
_.uniqBy             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/data.js
_.clone             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/data.js
_.toArray             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/data.js
_.escape             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/lib/chart_title.js
_.uniq             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_init_x_axis.ts
_.partial             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_injection.test.js
_.keys             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_injection.test.js
_.findIndex             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_fill_data_array.js
_.constant             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/tooltip.js
_.once             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/tooltip.js
_.random             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/position_tooltip.test.js
_.drop             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/position_tooltip.test.js
_.mergeWith             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/position_tooltip.js
_.forEachRight             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/_hierarchical_tooltip_formatter.js
_.repeat             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/tooltip/_hierarchical_tooltip_formatter.js
_.every             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/legend/legend.tsx
_.findLast             OpenSearch-Dashboards/src/plugins/vis_default_editor/public/components/sidebar/data_tab.tsx
_.compact             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/legend/legend.tsx
_.chain             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/vislib/components/labels/labels.test.js
_.upperFirst             OpenSearch-Dashboards/src/plugins/vis_type_vislib/public/components/options/metrics_axes/utils.ts
_.flatten             OpenSearch-Dashboards/src/plugins/vis_type_vega/public/lib/extract_index_pattern.ts
_.isPlainObject             OpenSearch-Dashboards/src/plugins/vis_type_vega/public/data_model/vega_parser.ts
_.sum             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/_series_agg.js
_.zip             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/_series_agg.js
_.startsWith             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.js
_.isEmpty             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/buckets.js
_.includes             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.js
._gt, .gte, .lt             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/public/application/components/vis_types/top_n/vis.js
_.snakeCase             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/public/application/components/lib/convert_series_to_vars.js
_.debounce             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/public/application/components/vis_editor.js
_.isBoolean             OpenSearch-Dashboards/src/plugins/vis_type_timeseries/public/application/components/add_delete_buttons.tsx
_.mapValues             OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/series_functions/opensearch/lib/agg_response_to_series_list.js
_.fill             OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/series_functions/aggregate/index.js
_.fromPairs             OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/lib/load_functions.js
_.extend             OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/lib/functions_md.js
_.without             OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/lib/functions_md.js
_.difference             OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/handlers/lib/validate_arg.js
_.throttle             OpenSearch-Dashboards/src/plugins/vis_type_tagcloud/public/components/tag_cloud_chart.tsx
_.findLastIndex             OpenSearch-Dashboards/src/plugins/timeline/public/directives/cells/collection.ts
_.words             OpenSearch-Dashboards/src/plugins/timeline/public/directives/saved_object_finder.js
_.capitalize             OpenSearch-Dashboards/src/plugins/timeline/public/directives/saved_object_finder.js
_.assignIn             OpenSearch-Dashboards/src/plugins/timeline/public/app.js
_.round             OpenSearch-Dashboards/src/plugins/tile_map/public/tile_map_visualization.js
_.trim              
_.trimStart             OpenSearch-Dashboards/src/plugins/data/common/field_formats/field_format.test.ts
_.trimEnd             OpenSearch-Dashboards/src/plugins/data/common/field_formats/field_format.test.ts
_.take             OpenSearch-Dashboards/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx
_.getField             OpenSearch-Dashboards/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx
_.mapKeys             OpenSearch-Dashboards/src/plugins/saved_objects_management/public/lib/case_conversion.ts
_.padStart             OpenSearch-Dashboards/src/plugins/opensearch_ui_shared/public/components/cron_editor/cron_editor.js
_.pad             OpenSearch-Dashboards/src/legacy/server/logging/log_format_string.js
_.transform             OpenSearch-Dashboards/src/plugins/opensearch_dashboards_utils/common/url/encode_uri_query.ts
_.escapeRegExp             OpenSearch-Dashboards/src/plugins/opensearch_dashboards_utils/common/field_wildcard.ts
_.parseInt             OpenSearch-Dashboards/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.js
_.intersection             OpenSearch-Dashboards/src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsxOpenSearch-Dashboards/src/cli/cli.js
_.zipObject             OpenSearch-Dashboards/src/plugins/expressions/common/expression_types/specs/datatable.ts
_.shuffle             OpenSearch-Dashboards/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_capabilities.test.js
_.hasIn             OpenSearch-Dashboards/src/plugins/data/public/search/expressions/opensearchaggs.ts
_.trimEnd             OpenSearch-Dashboards/src/plugins/data/public/search/search_interceptor.ts
_.partition             OpenSearch-Dashboards/src/plugins/data/public/query/timefilter/lib/extract_time_filter.ts
.take, .remove             OpenSearch-Dashboards/src/plugins/data/public/query/persisted_log/persisted_log.ts
_.reduceRight             OpenSearch-Dashboards/src/plugins/data/public/query/filter_manager/lib/map_filter.ts
_.findKey             OpenSearch-Dashboards/src/plugins/data/common/search/tabify/buckets.ts
_.setWith ->@elastic/safer-lodash-set             OpenSearch-Dashboards/src/plugins/data/common/search/search_source/search_source.ts
_.startCase             OpenSearch-Dashboards/src/plugins/data/common/search/aggs/metrics/lib/make_nested_label.ts
_.dropRight             OpenSearch-Dashboards/src/plugins/data/common/search/aggs/metrics/top_hit.test.ts
_.reject             OpenSearch-Dashboards/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
_.truncate             OpenSearch-Dashboards/src/plugins/data/common/field_formats/converters/truncate.ts
_.head             OpenSearch-Dashboards/src/plugins/console/server/lib/opensearch_proxy_config.ts
_.some             OpenSearch-Dashboards/src/plugins/console/public/lib/autocomplete/components/list_component.js
_.sampleSize             OpenSearch-Dashboards/src/plugins/charts/public/services/colors/mapped_colors.ts
_.toPath             OpenSearch-Dashboards/src/legacy/utils/unset.ts
_.range             OpenSearch-Dashboards/src/fixtures/agg_resp/geohash_grid.js
_.delay             OpenSearch-Dashboards/src/cli_plugin/install/rename.js
_.padEnd             OpenSearch-Dashboards/src/cli/help.js
_.wrap             OpenSearch-Dashboards/src/cli/command.js
nurSaadat commented 1 year ago

@Aigerim-ai I really like the idea with the package that helps us to replace all the functions.

I also would like to propose dividing migration into logical parts by plugin. We have several affected plugins as well as files outside of them. The latter can be done later in a more granular way.

Aigerim-ai commented 1 year ago

Dear @nurSaadat, I have already got the approval from @ashwin-pc and working on the replacement, please look at the issue I have created

Aigerim-ai commented 1 year ago

@ashwin-pc could you please assign this issue for me?

nurSaadat commented 1 year ago

Replacing the functions can be done by creating separate issues for each subtask.

Lodash methods are currently can be found in 813 files, here is the list

Question: Is it safe to ignore .eslint.rc.js files?

My approach would be to change the methods package by package, plugin by plugin. To be specific that would include 93 different subtasks listed in this file

I'd like to use this conversion table created by research and discussions with ChatGPT.

I think it would be neat to create separate issues for each subtask for discussion and easier navigation.

References to resources used: https://www.sitepoint.com/lodash-features-replace-es6/ https://blog.bitsrc.io/you-dont-need-lodash-or-how-i-started-loving-javascript-functions-3f45791fa6cd