Skip to content

Commit

Permalink
chore: rename rule from no-raw-selectors to no-raw-locators
Browse files Browse the repository at this point in the history
  • Loading branch information
Haberkamp committed Aug 27, 2023
1 parent 84138cc commit 5f91eab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 noRawLocator 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';
Expand Down Expand Up @@ -103,7 +103,7 @@ export = {
'no-networkidle': noNetworkidle,
'no-nth-methods': noNthMethods,
'no-page-pause': noPagePause,
'no-raw-selector': noRawSelector,
'no-raw-locator': noRawLocator,
'no-restricted-matchers': noRestrictedMatchers,
'no-skipped-test': noSkippedTest,
'no-useless-await': noUselessAwait,
Expand Down
10 changes: 5 additions & 5 deletions src/rules/no-raw-selector.ts → src/rules/no-raw-locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ export default {
const method = getStringValue(node.callee.property);

if (isPageMethod(node, 'locator') || method === 'locator') {
context.report({ messageId: 'noRawSelector', node });
context.report({ messageId: 'noRawLocator', node });
}
},
};
},
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',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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()'),
Expand Down

0 comments on commit 5f91eab

Please sign in to comment.