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

[Security Solutions] Removes tech debt of exporting all from linter rule for security_solution plugin #120188

Merged

Conversation

FrankHassanabad
Copy link
Contributor

@FrankHassanabad FrankHassanabad commented Dec 2, 2021

Summary

See: #110903

This removes the top level API export * spots from:

  • security_solution plugin

by removing all the exports from security_solution/common/index.ts since non of those were shared outside this plugin. Look at the metrics from the build below and you will see huge drops off numbers across the board for required API documentation to the page load size.

In the file security_solution/common/index.ts I now put the advice of:

// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.

But really I doubt we will have to share anything from security_solutions plugin to another plugin or expose it for anyone else. So I think this is 👍 the way forward to not expose anything directly from security_solution/common/index.ts anymore.

@FrankHassanabad FrankHassanabad self-assigned this Dec 2, 2021
@FrankHassanabad FrankHassanabad added v8.0.0 v8.1.0 release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed labels Dec 2, 2021
@FrankHassanabad FrankHassanabad changed the title Fix export security solution [Security Solutions] Removes tech debt of exporting all from linter rule for security_solution plugin Dec 2, 2021
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
securitySolution 1325 44 -1281

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
securitySolution 4 0 -4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 4.6MB 4.6MB -345.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
securitySolution 33 17 -16

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 249.5KB 243.7KB -5.8KB
Unknown metric groups

API count

id before after diff
securitySolution 1374 44 -1330

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @FrankHassanabad

@FrankHassanabad FrankHassanabad marked this pull request as ready for review December 2, 2021 06:14
@FrankHassanabad FrankHassanabad requested review from a team as code owners December 2, 2021 06:14
@@ -14,7 +14,7 @@ import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { useRuleWithFallback } from '../../../detections/containers/detection_engine/rules/use_rule_with_fallback';

import { TestProviders, TestProvidersComponent } from '../../mock';
import { TimelineId } from '../../../../common';
import { TimelineId } from '../../../../common/types';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be a import type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can, but most of the times these are auto-inferred by typescript. There are linter rules for forcing these with an auto-fix as well so I am not going to overly worry about them in these few cases for this PR.

@@ -14,7 +14,8 @@ import { BrowserFields } from '../../containers/source';
import { OnUpdateColumns } from '../../../timelines/components/timeline/events';
import * as i18n from './translations';
import { EventFieldsData } from './types';
import { BrowserField, ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, can these be import type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can, but most of the times these are auto-inferred by typescript. There are linter rules for forcing these with an auto-fix as well so I am not going to overly worry about them in these few cases for this PR.

Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - left a few comments where I wasn't sure if it was worth doing import type vs import but I know that wasn't the main concern of this PR.

@FrankHassanabad FrankHassanabad removed the auto-backport Deprecated - use backport:version if exact versions are needed label Dec 2, 2021
@FrankHassanabad FrankHassanabad merged commit 9152065 into elastic:main Dec 2, 2021
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Dec 2, 2021
…ule for security_solution plugin (elastic#120188)

## Summary

See: elastic#110903

This removes the top level API `export *` spots from:
* `security_solution` plugin

by removing _all_ the exports from `security_solution/common/index.ts` since non of those were shared outside this plugin. Look at the metrics from the build below and you will see _huge_ drops off numbers across the board for required API documentation to the page load size.

In the file `security_solution/common/index.ts` I now put the advice of:

 ```
// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.
```

But really I doubt we will have to share anything from `security_solutions` plugin to another plugin or expose it for anyone else. So I think this is 👍 the way forward to not expose anything directly from `security_solution/common/index.ts` anymore.
@FrankHassanabad FrankHassanabad deleted the fix-export-security-solution branch December 2, 2021 20:38
FrankHassanabad added a commit that referenced this pull request Dec 2, 2021
…ule for security_solution plugin (#120188) (#120270)

## Summary

See: #110903

This removes the top level API `export *` spots from:
* `security_solution` plugin

by removing _all_ the exports from `security_solution/common/index.ts` since non of those were shared outside this plugin. Look at the metrics from the build below and you will see _huge_ drops off numbers across the board for required API documentation to the page load size.

In the file `security_solution/common/index.ts` I now put the advice of:

 ```
// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.
```

But really I doubt we will have to share anything from `security_solutions` plugin to another plugin or expose it for anyone else. So I think this is 👍 the way forward to not expose anything directly from `security_solution/common/index.ts` anymore.
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
…ule for security_solution plugin (elastic#120188)

## Summary

See: elastic#110903

This removes the top level API `export *` spots from:
* `security_solution` plugin

by removing _all_ the exports from `security_solution/common/index.ts` since non of those were shared outside this plugin. Look at the metrics from the build below and you will see _huge_ drops off numbers across the board for required API documentation to the page load size.

In the file `security_solution/common/index.ts` I now put the advice of:

 ```
// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.
```

But really I doubt we will have to share anything from `security_solutions` plugin to another plugin or expose it for anyone else. So I think this is 👍 the way forward to not expose anything directly from `security_solution/common/index.ts` anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants