diff --git a/docs/rules/prefer-user-facing-locators.md b/docs/rules/no-raw-locators.md similarity index 75% rename from docs/rules/prefer-user-facing-locators.md rename to docs/rules/no-raw-locators.md index b4857ea..757875f 100644 --- a/docs/rules/prefer-user-facing-locators.md +++ b/docs/rules/no-raw-locators.md @@ -1,6 +1,6 @@ -## Disallow using raw selectors (`no-raw-selector`) +## Disallow using raw locators (`no-raw-locators`) -Prefer using user-facing locators over raw selectors to make tests more robust. +Prefer using user-facing locators over raw locators to make tests more robust. Check out the [Playwright documentation](https://playwright.dev/docs/locators) for more information. diff --git a/src/index.ts b/src/index.ts index 870662b..5f4981f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ import noNestedStep from './rules/no-nested-step'; import noNetworkidle from './rules/no-networkidle'; import noNthMethods from './rules/no-nth-methods'; import noPagePause from './rules/no-page-pause'; -import noRawSelector from './rules/no-raw-selector'; +import noRawLocators from './rules/no-raw-locators'; import noRestrictedMatchers from './rules/no-restricted-matchers'; import noSkippedTest from './rules/no-skipped-test'; import noUselessAwait from './rules/no-useless-await'; @@ -103,7 +103,7 @@ export = { 'no-networkidle': noNetworkidle, 'no-nth-methods': noNthMethods, 'no-page-pause': noPagePause, - 'no-raw-selector': noRawSelector, + 'no-raw-locators': noRawLocators, 'no-restricted-matchers': noRestrictedMatchers, 'no-skipped-test': noSkippedTest, 'no-useless-await': noUselessAwait, diff --git a/src/rules/no-raw-selector.ts b/src/rules/no-raw-locators.ts similarity index 66% rename from src/rules/no-raw-selector.ts rename to src/rules/no-raw-locators.ts index 1e318cb..90b1a8f 100644 --- a/src/rules/no-raw-selector.ts +++ b/src/rules/no-raw-locators.ts @@ -9,7 +9,7 @@ export default { const method = getStringValue(node.callee.property); if (isPageMethod(node, 'locator') || method === 'locator') { - context.report({ messageId: 'noRawSelector', node }); + context.report({ messageId: 'noRawLocator', node }); } }, }; @@ -17,13 +17,13 @@ export default { meta: { docs: { category: 'Best Practices', - description: 'Disallows the usage of raw selectors', + description: 'Disallows the usage of raw locators', recommended: false, - url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-raw-selector.md', + url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-raw-locators.md', }, messages: { - noRawSelector: - 'Usage of raw selector detected. Use methods like .getByRole() or .getByText() instead of raw selectors.', + noRawLocator: + 'Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators.', }, type: 'suggestion', }, diff --git a/test/spec/no-raw-selector.spec.ts b/test/spec/no-raw-locators.spec.ts similarity index 95% rename from test/spec/no-raw-selector.spec.ts rename to test/spec/no-raw-locators.spec.ts index 82c0f63..1936354 100644 --- a/test/spec/no-raw-selector.spec.ts +++ b/test/spec/no-raw-locators.spec.ts @@ -1,9 +1,9 @@ -import rule from '../../src/rules/no-raw-selector'; +import rule from '../../src/rules/no-raw-locators'; import { runRuleTester, test } from '../utils/rule-tester'; const messageId = 'noRawSelector'; -runRuleTester('no-raw-selector', rule, { +runRuleTester('no-raw-locators', rule, { invalid: [ { code: test('await page.locator()'),