Skip to content

Commit

Permalink
Enable "Event Generating Elements Should Be Instrumented" ESLint rule…
Browse files Browse the repository at this point in the history
… for more O11y Apps (#165647)

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
CoenWarmer and kibanamachine authored Sep 5, 2023
1 parent 33dcda7 commit 772bc0c
Show file tree
Hide file tree
Showing 80 changed files with 172 additions and 20 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,15 @@ module.exports = {
{
files: [
'x-pack/plugins/apm/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/exploratory_view/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/ux/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/synthetics/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/infra/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_ai_assistant/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_onboarding/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_shared/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/profiling/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/synthetics/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/ux/**/*.{js,mjs,ts,tsx}',
],
rules: {
'@kbn/telemetry/event_generating_elements_should_be_instrumented': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function checkNodeForExistingDataTestSubjProp(
const variable = getScope().variables.find((v) => v.name === name); // the variable definition of the spreaded variable

return variable && variable.defs.length > 0
? variable.defs[0].node.init.properties.find((property: TSESTree.Property) => {
? variable.defs[0].node.init?.properties.find((property: TSESTree.Property) => {
if ('value' in property.key) {
return property.key.value === 'data-test-subj';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ for (const [name, tester] of [tsTester, babelTester]) {
],
output: `<${element} data-test-subj="Value${element
.replace('Eui', '')
.replace('Empty', '')}">Value</${element}>`,
.replace('Empty', '')
.replace('Icon', '')}">Value</${element}>`,
})),
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getFunctionName } from '../helpers/get_function_name';
export const EVENT_GENERATING_ELEMENTS = [
'EuiButton',
'EuiButtonEmpty',
'EuiButtonIcon',
'EuiLink',
'EuiFieldText',
'EuiFieldSearch',
Expand Down Expand Up @@ -74,7 +75,7 @@ export const EventGeneratingElementsShouldBeInstrumented: Rule.RuleModule = {
const intent = getIntentFromNode(parent);

// 4. The element name that generates the events
const element = name.replace('Eui', '').replace('Empty', '');
const element = name.replace('Eui', '').replace('Empty', '').replace('Icon', '');

const suggestion = `${appName}${componentName}${intent}${element}`; // 'o11yHeaderActionsSubmitButton'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function HelpPopoverButton({

return (
<EuiButtonIcon
data-test-subj="apmHelpPopoverButtonButton"
className="apmHelpPopover__buttonIcon"
size="s"
iconType="help"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function ConfigurationValueColumn({
</EuiText>
{value && (
<EuiButtonIcon
data-test-subj="apmConfigurationValueColumnButton"
aria-label={i18n.translate(
'xpack.apm.onboarding.column.value.copyIconText',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function ConfigurationValueColumn({
</EuiText>
{value && (
<EuiButtonIcon
data-test-subj="apmConfigurationValueColumnButton"
aria-label={i18n.translate(
'xpack.apm.onboarding.otel.column.value.copyIconText',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export function AgentConfigurationList({
name: '',
render: (config: Config) => (
<EuiButtonIcon
data-test-subj="apmColumnsButton"
aria-label="Edit"
iconType="pencil"
href={apmRouter.link('/settings/agent-configuration/edit', {
Expand All @@ -218,6 +219,7 @@ export function AgentConfigurationList({
name: '',
render: (config: Config) => (
<EuiButtonIcon
data-test-subj="apmColumnsButton"
aria-label="Delete"
iconType="trash"
onClick={() => setConfigToBeDeleted(config)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function AgentKeyCallOut({ name, token }: Props) {
<EuiCopy textToCopy={token}>
{(copy) => (
<EuiButtonIcon
data-test-subj="apmAgentKeyCallOutButton"
iconType="copyClipboard"
onClick={copy}
color="success"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function DiscoveryRule({
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="apmDiscoveryRuleButton"
iconType="pencil"
color="primary"
onClick={() => {
Expand All @@ -108,6 +109,7 @@ export function DiscoveryRule({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="apmDiscoveryRuleButton"
iconType="trash"
color="danger"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function PopoverTooltip({
closePopover={() => setIsPopoverOpen(false)}
button={
<EuiButtonIcon
data-test-subj="apmPopoverTooltipButton"
aria-label={ariaLabel}
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
setIsPopoverOpen(!isPopoverOpen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function SpanLinksTable({ items }: Props) {
<EuiPopover
button={
<EuiButtonIcon
data-test-subj="apmColumnsButton"
aria-label="Edit"
iconType="boxesHorizontal"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function OpenTelemetryInstructions({
</EuiText>
{value && (
<EuiButtonIcon
data-test-subj="apmColumnsButton"
aria-label={i18n.translate(
'xpack.apm.tutorial.config_otel.column.value.copyIconText',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export function SelectableUrlList({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="exploratoryViewPopOverTitleButton"
color="text"
onClick={() => closePopover()}
aria-label={i18n.translate('xpack.exploratoryView.search.url.close', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function SeriesActions({ seriesId, series, seriesConfig, onEditClick }: P

const popoverButton = (
<EuiButtonIcon
data-test-subj="exploratoryViewSeriesActionsButton"
iconType="boxesHorizontal"
onClick={changePopoverVisibility}
color="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function SeriesName({ series, seriesId }: Props) {
)}
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="exploratoryViewSeriesNameButton"
onClick={() => setIsEditingEnabled(!isEditingEnabled)}
iconType="pencil"
aria-label={i18n.translate('xpack.exploratoryView.expView.seriesEditor.editName', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ export const ExpressionRow: React.FC<ExpressionRowProps> = (props) => {
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraExpressionRowButton"
iconType={isExpanded ? 'arrowDown' : 'arrowRight'}
onClick={toggle}
aria-label={i18n.translate('xpack.infra.metrics.alertFlyout.expandRowLabel', {
Expand Down Expand Up @@ -629,6 +630,7 @@ export const ExpressionRow: React.FC<ExpressionRowProps> = (props) => {
/>
</StyledHealth>
<EuiButtonIcon
data-test-subj="infraExpressionRowButton"
aria-label={i18n.translate(
'xpack.infra.metrics.alertFlyout.removeWarningThreshold',
{
Expand Down Expand Up @@ -668,6 +670,7 @@ export const ExpressionRow: React.FC<ExpressionRowProps> = (props) => {
{canDelete && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraExpressionRowButton"
aria-label={i18n.translate('xpack.infra.metrics.alertFlyout.removeCondition', {
defaultMessage: 'Remove condition',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export const ClosablePopoverTitle = ({ children, onClose }: ClosablePopoverTitle
<EuiFlexItem>{children}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraClosablePopoverTitleButton"
iconType="cross"
color="danger"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const ClosablePopoverTitle = ({ children, onClose }: ClosablePopoverTitle
<EuiFlexItem>{children}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraClosablePopoverTitleButton"
iconType="cross"
color="danger"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export const Criterion: React.FC<Props> = ({
{canDelete && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraCriterionButton"
aria-label={i18n.translate('xpack.infra.logs.alertFlyout.removeCondition', {
defaultMessage: 'Remove condition',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const ClosablePopoverTitle = ({ children, onClose }: ClosablePopoverTitle
<EuiFlexItem>{children}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraClosablePopoverTitleButton"
iconType="cross"
color="danger"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const ClosablePopoverTitle = ({ children, onClose }: ClosablePopoverTitle
<EuiFlexItem>{children}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraClosablePopoverTitleButton"
iconType="cross"
color="danger"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const MetricRowControls = ({ onDelete, disableDelete }: MetricRowControlP
<>
<EuiFlexItem grow={0}>
<EuiButtonIcon
data-test-subj="infraMetricRowControlsButton"
iconType="trash"
color="danger"
style={{ marginBottom: '0.2em' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export const ExpressionRow: React.FC<ExpressionRowProps> = (props) => {
/>
</StyledHealth>
<EuiButtonIcon
data-test-subj="infraExpressionRowButton"
aria-label={i18n.translate(
'xpack.infra.metrics.alertFlyout.removeWarningThreshold',
{
Expand Down Expand Up @@ -350,6 +351,7 @@ export const ExpressionRow: React.FC<ExpressionRowProps> = (props) => {
{canDelete && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraExpressionRowButton"
aria-label={i18n.translate('xpack.infra.metrics.alertFlyout.removeCondition', {
defaultMessage: 'Remove condition',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const RowExpansionButton = <Item extends any>({

return (
<EuiButtonIcon
data-test-subj="infraRowExpansionButtonButton"
onClick={handleClick}
aria-label={isExpanded ? collapseAriaLabel : expandAriaLabel}
iconType={isExpanded ? 'arrowUp' : 'arrowDown'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const LogHighlightsMenu: React.FC<LogHighlightsMenuProps> = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraLogHighlightsMenuButton"
aria-label={goToPreviousHighlightLabel}
iconType="arrowUp"
onClick={goToPreviousHighlight}
Expand All @@ -123,6 +124,7 @@ export const LogHighlightsMenu: React.FC<LogHighlightsMenuProps> = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraLogHighlightsMenuButton"
aria-label={goToNextHighlightLabel}
iconType="arrowDown"
onClick={goToNextHighlight}
Expand All @@ -132,6 +134,7 @@ export const LogHighlightsMenu: React.FC<LogHighlightsMenuProps> = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="infraLogHighlightsMenuButton"
aria-label={clearTermsButtonLabel}
color="danger"
isDisabled={highlightTerm === ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function HideableReactQueryDevTools() {
return !isHidden ? (
<div>
<EuiButtonIcon
data-test-subj="infraHideableReactQueryDevToolsButton"
iconType="cross"
color="primary"
style={{ zIndex: 99999, position: 'fixed', bottom: '40px', left: '40px' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ const PaginationControls = ({
<EuiFlexItem grow={false}>
<EuiFlexGroup>
<EuiButtonIcon
data-test-subj="infraPaginationControlsButton"
iconType="arrowLeft"
isDisabled={!fetchPreviousPage || isLoading}
onClick={fetchPreviousPage}
Expand All @@ -308,6 +309,7 @@ const PaginationControls = ({
<strong>{page}</strong>
</span>
<EuiButtonIcon
data-test-subj="infraPaginationControlsButton"
iconType="arrowRight"
isDisabled={!fetchNextPage || isLoading}
onClick={fetchNextPage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const AnomalyActionMenu = ({
panelPaddingSize="none"
button={
<EuiButtonIcon
data-test-subj="infraAnomalyActionMenuButton"
iconType="boxesHorizontal"
onClick={handleToggleMenu}
aria-label={i18n.translate('xpack.infra.ml.anomalyFlyout.actions.openActionMenu', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const PaginationControls = ({
<EuiFlexItem grow={false}>
<EuiFlexGroup>
<EuiButtonIcon
data-test-subj="infraPaginationControlsButton"
iconType="arrowLeft"
isDisabled={!fetchPreviousPage || isLoading}
onClick={fetchPreviousPage}
Expand All @@ -45,6 +46,7 @@ export const PaginationControls = ({
<strong>{page}</strong>
</span>
<EuiButtonIcon
data-test-subj="infraPaginationControlsButton"
iconType="arrowRight"
isDisabled={!fetchNextPage || isLoading}
onClick={fetchNextPage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export const NodeContextPopover = ({
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon size="s" onClick={onClose} iconType="cross" />
<EuiButtonIcon
data-test-subj="infraNodeContextPopoverButton"
size="s"
onClick={onClose}
iconType="cross"
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const Table = (props: Props) => {
)}
>
<EuiButtonIcon
data-test-subj="infraColumnsButton"
color="text"
size="s"
iconType="filter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const MetricsEditMode = withTheme(
>
<EuiFlexItem grow={false} style={{ width: ICON_WIDTH }}>
<EuiButtonIcon
data-test-subj="infraMetricsEditModeButton"
iconType="pencil"
onClick={() => onEdit(metric)}
aria-label={i18n.translate(
Expand All @@ -55,6 +56,7 @@ export const MetricsEditMode = withTheme(
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ width: ICON_WIDTH, textAlign: 'right' }}>
<EuiButtonIcon
data-test-subj="infraMetricsEditModeButton"
iconType="trash"
color="danger"
onClick={() => onDelete(metric)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export const MetadataDetails = (props: Props) => {
{filteredFields.length > NUMBER_OF_COLUMNS ? (
<Controls>
<EuiButtonIcon
data-test-subj="infraMetadataDetailsButton"
iconType={isOpen ? 'arrowUp' : 'arrowDown'}
onClick={toggleIsOpen}
aria-label={i18n.translate('xpack.infra.nodeDetails.labels.showMoreDetails', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function ClosablePopoverTitle({ children, onClose }: ClosablePopoverTitle
<EuiFlexItem>{children}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="o11yClosablePopoverTitleButton"
iconType="cross"
color="danger"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function MetricRowControls({ onDelete, disableDelete }: MetricRowControlP
<>
<EuiFlexItem grow={0}>
<EuiButtonIcon
data-test-subj="o11yMetricRowControlsButton"
aria-label={DELETE_LABEL}
iconType="trash"
color="danger"
Expand Down
Loading

0 comments on commit 772bc0c

Please sign in to comment.