Chore: Fix e2e-selectors eslint rule to check for `startsWith` (#111733)

This commit is contained in:
Tom Ratcliffe 2025-09-29 16:02:34 +01:00 committed by GitHub
parent 410df3d065
commit a243259063
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 1 deletions

View File

@ -4484,6 +4484,11 @@
"count": 1
}
},
"public/app/plugins/panel/geomap/components/DebugOverlay.tsx": {
"@grafana/no-aria-label-selectors": {
"count": 1
}
},
"public/app/plugins/panel/geomap/components/MarkersLegend.tsx": {
"@typescript-eslint/consistent-type-assertions": {
"count": 2

View File

@ -50,7 +50,7 @@ const rule = createRule({
(v) =>
v.type === 'ImportBinding' &&
v.parent.type === 'ImportDeclaration' &&
v.parent.source.value === GRAFANA_E2E_PACKAGE_NAME
v.parent.source.value.startsWith(GRAFANA_E2E_PACKAGE_NAME)
);
if (importDef) {

View File

@ -19,12 +19,15 @@ const ruleTester = new RuleTester();
ruleTester.run('eslint no-aria-label-e2e-selector', noAriaLabelE2ESelector, {
valid: [
{
name: 'direct aria-label usage',
code: `<div aria-label="foo" />`,
},
{
name: 'basic jsx expression container aria-label usage',
code: `<div aria-label={"foo"} />`,
},
{
name: 'imported from something else',
code: `
import { someOtherImport } from './some-other-location';
@ -34,9 +37,23 @@ import { someOtherImport } from './some-other-location';
],
invalid: [
{
name: 'imported from e2e-selectors package',
code: `
import { selectors } from '@grafana/e2e-selectors';
<div aria-label={selectors.pages.AddDashboard.addNewPanel} />
`,
errors: [
{
message: 'Use data-testid for E2E selectors instead of aria-label',
},
],
},
{
name: 'imported from elsewhere in e2e-selectors package',
code: `
import { selectors } from '@grafana/e2e-selectors/src';
<div aria-label={selectors.pages.AddDashboard.addNewPanel} />
`,
errors: [