mirror of https://github.com/grafana/grafana.git
Chore: Fix e2e-selectors eslint rule to check for `startsWith` (#111733)
This commit is contained in:
parent
410df3d065
commit
a243259063
|
@ -4484,6 +4484,11 @@
|
||||||
"count": 1
|
"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": {
|
"public/app/plugins/panel/geomap/components/MarkersLegend.tsx": {
|
||||||
"@typescript-eslint/consistent-type-assertions": {
|
"@typescript-eslint/consistent-type-assertions": {
|
||||||
"count": 2
|
"count": 2
|
||||||
|
|
|
@ -50,7 +50,7 @@ const rule = createRule({
|
||||||
(v) =>
|
(v) =>
|
||||||
v.type === 'ImportBinding' &&
|
v.type === 'ImportBinding' &&
|
||||||
v.parent.type === 'ImportDeclaration' &&
|
v.parent.type === 'ImportDeclaration' &&
|
||||||
v.parent.source.value === GRAFANA_E2E_PACKAGE_NAME
|
v.parent.source.value.startsWith(GRAFANA_E2E_PACKAGE_NAME)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (importDef) {
|
if (importDef) {
|
||||||
|
|
|
@ -19,12 +19,15 @@ const ruleTester = new RuleTester();
|
||||||
ruleTester.run('eslint no-aria-label-e2e-selector', noAriaLabelE2ESelector, {
|
ruleTester.run('eslint no-aria-label-e2e-selector', noAriaLabelE2ESelector, {
|
||||||
valid: [
|
valid: [
|
||||||
{
|
{
|
||||||
|
name: 'direct aria-label usage',
|
||||||
code: `<div aria-label="foo" />`,
|
code: `<div aria-label="foo" />`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: 'basic jsx expression container aria-label usage',
|
||||||
code: `<div aria-label={"foo"} />`,
|
code: `<div aria-label={"foo"} />`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: 'imported from something else',
|
||||||
code: `
|
code: `
|
||||||
import { someOtherImport } from './some-other-location';
|
import { someOtherImport } from './some-other-location';
|
||||||
|
|
||||||
|
@ -34,9 +37,23 @@ import { someOtherImport } from './some-other-location';
|
||||||
],
|
],
|
||||||
invalid: [
|
invalid: [
|
||||||
{
|
{
|
||||||
|
name: 'imported from e2e-selectors package',
|
||||||
code: `
|
code: `
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
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} />
|
<div aria-label={selectors.pages.AddDashboard.addNewPanel} />
|
||||||
`,
|
`,
|
||||||
errors: [
|
errors: [
|
||||||
|
|
Loading…
Reference in New Issue