Skip to content

Conversation

@jtgober
Copy link
Contributor

@jtgober jtgober commented Sep 5, 2025

This allows for regex to be used with the expect-expect linting option. I've also tested this on a quick sample project. where rules:

rules: {
 'playwright/expect-expect': ['error', {
  assertFunctionNames: ['myCustomAssert'],
  assertFunctionPatterns: ['^verify.*', '^check.*', '.*Assertion$']
}]
 ...
}

works for example tests


Note

Adds assertFunctionPatterns to treat regex-matched functions as assertions in expect-expect, with updated schema, docs, and tests.

  • Rule (src/rules/expect-expect.ts):
    • Add assertFunctionPatterns option (array of regex strings) and compile to RegExps.
    • Introduce matches helper to check custom assertion names and regex patterns.
    • Integrate into CallExpression handling; update options parsing and schema to include assertFunctionPatterns.
  • Tests (src/rules/expect-expect.test.ts):
    • Add valid cases for regex-matched assertions and mixed name/pattern usage.
    • Add invalid case where custom function doesn’t match provided patterns.
  • Docs (docs/rules/expect-expect.md):
    • Document assertFunctionPatterns with examples and updated options snippet.
    • Clarify usage alongside assertFunctionNames.

Written by Cursor Bugbot for commit b9c2ab7. This will update automatically on new commits. Configure here.

@MSroczynski3
Copy link
Contributor

LGTM 😄 Just as described in the #316 . Minimal changes, tests added 👍

@mskelton mskelton merged commit fdd0253 into mskelton:main Nov 29, 2025
1 check passed
@github-actions
Copy link

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants