-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
ESLint Telemetry Rule #151173
Closed
Closed
ESLint Telemetry Rule #151173
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… feature/telemetry
6fa2a8d
to
859cf68
Compare
859cf68
to
d1c9023
Compare
…ana into feature/telemetry-renewed
Pinging @elastic/apm-ui (Team:APM) |
auto-merge was automatically disabled
March 6, 2023 12:31
Pull request was closed
⏳ Build in-progress, with failuresFailed CI StepsHistory
To update your PR or re-run it, just comment with: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature:Embedding
Embedding content via iFrame
release_note:skip
Skip the PR/issue when compiling release notes
Team:APM - DEPRECATED
Use Team:obs-ux-infra_services.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #144887
Summary
This PR adds an ESLint Plugin which checks
Eui
elements for the existence of adata-test-subj
prop, and tries to come up with a suggestion based on the context in which the element is used.Screen.Recording.2023-02-14.at.15.26.35.mov
Details
Why do this?
There is an increased push to move towards data driven feature development. In order to facilitate this, we need to have an increased focus on instrumenting user event generating elements in the Kibana codebase. This linting rule is an attempt to nudge Kibana engineers to not forget to add this property when writing frontend code. It also saves a bit of work for engineers by suggesting a value for the
data-test-subj
based on the location of the file in the codebase and any potential default values that might be present in the JSX node tree. Finally, because the suggestion is always of the same form, it can increase the consistency in the values given to these elements.Shape of the suggestion
The suggestion for the value of data-test-subj is of the form:
[app][componentName][intent][euiElementName]
.For example, when working in a component in the location:
x-pack/plugins/observability/public/pages/overview/containers/overview_page/header_actions.tsx
, and having the code:the suggestion becomes:
data-test-subj=o11yHeaderActionsSubmitFormButton
.Which elements are checked by the ESLint rule?
In its current iteration the rule checks these Eui elements:
For elements that don't take a
defaultMessage
prop / translation, the suggestion takes the form:[app][componentName][euiElementName]
What types of function declarations does this rule support?
function Foo(){}
(Named function)const Foo = () => {}
(Arrow function assigned to variable)const Foo = memo(() => {})
(Arrow function assigned to variable wrapped in function)const Foo = hoc(uponHoc(uponHoc(() => {})))
(Arrow function assigned to variable wrapped in infinite levels of functions)Known limitations
data-test-subj
the rule will not kick in as any existing instrumentation will depend on the value.