// Playwright-specific ESLint rules
// see: https://github.com/playwright-community/eslint-plugin-playwright#rules

export default {
  // Prevent focused tests (.only)
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-focused-test.md
  'playwright/no-focused-test': 'error',

  // Enforce assertion to be made in a test body
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/expect-expect.md
  'playwright/expect-expect': 'error',

  // Enforce Playwright APIs to be awaited
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/missing-playwright-await.md
  'playwright/missing-playwright-await': 'error',

  // Enforces a maximum depth to nested describe calls
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/max-nested-describe.md
  'playwright/max-nested-describe': 'error',

  // Prevent calling `expect` conditionally
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-conditional-expect.md
  'playwright/no-conditional-expect': 'error',

  // Disallow conditional logic in tests
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-conditional-in-test.md
  'playwright/no-conditional-in-test': 'error',

  // Disallow commented out tests
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-commented-out-tests.md
  'playwright/no-commented-out-tests': 'error',

  // Disallow duplicate setup and teardown hooks
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-duplicate-hooks.md
  'playwright/no-duplicate-hooks': 'error',

  // Disallow usage of element handles (prefer locators)
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-element-handle.md
  'playwright/no-element-handle': 'error',

  // Disallow usage of `page.$eval()` and `page.$$eval()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-eval.md
  'playwright/no-eval': 'error',

  // Disallow usage of the `{ force: true }` option
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-force-option.md
  'playwright/no-force-option': 'error',

  // Disallow using `getByTitle()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-get-by-title.md
  'playwright/no-get-by-title': 'error',

  // Disallow setup and teardown hooks
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-hooks.md
  // decision: hooks are useful for setup and teardown, similar to Jest configuration
  'playwright/no-hooks': 'off',

  // Disallow nested `test.step()` methods
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-nested-step.md
  'playwright/no-nested-step': 'error',

  // Disallow usage of the `networkidle` option
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-networkidle.md
  'playwright/no-networkidle': 'error',

  // Disallow using `page.pause()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-page-pause.md
  'playwright/no-page-pause': 'error',

  // Disallow using raw locators
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-raw-locators.md
  'playwright/no-raw-locators': 'error',

  // Disallow usage of the `.skip` annotation
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-skipped-test.md
  // decision: it is often useful to be allowed to add a .skip, similar to Jest configuration
  'playwright/no-skipped-test': 'off',

  // Disallow using expect outside of `test` blocks
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-standalone-expect.md
  'playwright/no-standalone-expect': 'error',

  // Prevent unsafe variable references in `page.evaluate()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-unsafe-references.md
  'playwright/no-unsafe-references': 'error',

  // Disallow usage of page locators that are not used
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-unused-locators.md
  'playwright/no-unused-locators': 'error',

  // Disallow unnecessary `await`s for Playwright methods
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-useless-await.md
  'playwright/no-useless-await': 'error',

  // Disallow usage of `not` matchers when a specific matcher exists
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-useless-not.md
  'playwright/no-useless-not': 'error',

  // Disallow usage of `page.waitForNavigation()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-wait-for-navigation.md
  'playwright/no-wait-for-navigation': 'error',

  // Disallow usage of `page.waitForSelector()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-wait-for-selector.md
  'playwright/no-wait-for-selector': 'error',

  // Disallow usage of `page.waitForTimeout()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-wait-for-timeout.md
  'playwright/no-wait-for-timeout': 'error',

  // Suggest built-in locators over `page.locator()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-native-locators.md
  'playwright/prefer-native-locators': 'error',

  // Enforce lowercase test names
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
  // decision: descriptions are often named after React components which are capitalized, similar to Jest
  'playwright/prefer-lowercase-title': 'off',

  // Suggest using web first assertions
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-web-first-assertions.md
  'playwright/prefer-web-first-assertions': 'error',

  // Require setup and teardown code to be within a hook
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-hook.md
  'playwright/require-hook': 'error',

  // Enforce valid `describe()` callback
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/valid-describe-callback.md
  'playwright/valid-describe-callback': 'error',

  // Enforce valid `expect()` usage
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/valid-expect.md
  'playwright/valid-expect': 'error',

  // Enforce valid titles
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/valid-title.md
  'playwright/valid-title': 'error',

  // Enforces a maximum number of expects in a test
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/max-expects.md
  'playwright/max-expects': 'error',

  // Enforce valid `expect()` usage in promises
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/valid-expect-in-promise.md
  'playwright/valid-expect-in-promise': 'error',

  // Require test cases and hooks to be inside a `describe` block
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-top-level-describe.md
  'playwright/require-top-level-describe': 'error',

  // Enforce valid test tags
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/valid-test-tags.md
  'playwright/valid-test-tags': 'error',

  // Disallow usage of the `.slow()` annotation
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-slowed-test.md
  'playwright/no-slowed-test': 'error',

  // Disallow usage of nth methods
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-nth-methods.md
  'playwright/no-nth-methods': 'error',

  // Disallow specific matchers
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-restricted-matchers.md
  'playwright/no-restricted-matchers': 'off', // off by default, can be configured per project

  // Suggest using comparison matchers
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-comparison-matcher.md
  'playwright/prefer-comparison-matcher': 'error',

  // Suggest using equality matchers
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-equality-matcher.md
  'playwright/prefer-equality-matcher': 'error',

  // Enforce hook ordering
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-hooks-in-order.md
  'playwright/prefer-hooks-in-order': 'error',

  // Enforce hooks to be at the top of tests
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-hooks-on-top.md
  'playwright/prefer-hooks-on-top': 'error',

  // Suggest using `locator()` over other locator methods
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-locator.md
  'playwright/prefer-locator': 'error',

  // Suggest using `toStrictEqual()` over `toEqual()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-strict-equal.md
  'playwright/prefer-strict-equal': 'error',

  // Suggest using `toBe()` for primitive literals
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-be.md
  'playwright/prefer-to-be': 'error',

  // Suggest using `toContain()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-contain.md
  'playwright/prefer-to-contain': 'error',

  // Suggest using `toHaveCount()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-have-count.md
  'playwright/prefer-to-have-count': 'error',

  // Suggest using `toHaveLength()`
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-have-length.md
  'playwright/prefer-to-have-length': 'error',

  // Require soft assertions
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-soft-assertions.md
  // decision: off by default as it's project-specific
  'playwright/require-soft-assertions': 'off',

  // Require `toThrow()` to have a message
  // https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-to-throw-message.md
  'playwright/require-to-throw-message': 'error',
};
