-
Notifications
You must be signed in to change notification settings - Fork 51
feat: Add consistent-spacing-between-blocks
rule (#349)
#388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add consistent-spacing-between-blocks
rule (#349)
#388
Conversation
e0e16ec
to
3b6154f
Compare
3b6154f
to
9374973
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bug: Recommended Rule Not Enabled
The consistent-spacing-between-blocks
rule is marked as recommended in the README and its metadata, but it's not included in sharedConfig.rules
. This means the rule won't be enabled in the recommended configuration, contradicting its documented status.
src/index.ts#L57-L58
eslint-plugin-playwright/src/index.ts
Lines 57 to 58 in 9374973
rules: { | |
'consistent-spacing-between-blocks': consistentSpacingBetweenBlocks, |
src/index.ts#L97-L134
eslint-plugin-playwright/src/index.ts
Lines 97 to 134 in 9374973
'prefer-to-contain': preferToContain, | |
'prefer-to-have-count': preferToHaveCount, | |
'prefer-to-have-length': preferToHaveLength, | |
'prefer-web-first-assertions': preferWebFirstAssertions, | |
'require-hook': requireHook, | |
'require-soft-assertions': requireSoftAssertions, | |
'require-to-throw-message': requireToThrowMessage, | |
'require-top-level-describe': requireTopLevelDescribe, | |
'valid-describe-callback': validDescribeCallback, | |
'valid-expect': validExpect, | |
'valid-expect-in-promise': validExpectInPromise, | |
'valid-test-tags': validTestTags, | |
'valid-title': validTitle, | |
}, | |
} | |
const sharedConfig = { | |
rules: { | |
'no-empty-pattern': 'off', | |
'playwright/expect-expect': 'warn', | |
'playwright/max-nested-describe': 'warn', | |
'playwright/missing-playwright-await': 'error', | |
'playwright/no-conditional-expect': 'warn', | |
'playwright/no-conditional-in-test': 'warn', | |
'playwright/no-element-handle': 'warn', | |
'playwright/no-eval': 'warn', | |
'playwright/no-focused-test': 'error', | |
'playwright/no-force-option': 'warn', | |
'playwright/no-nested-step': 'warn', | |
'playwright/no-networkidle': 'error', | |
'playwright/no-page-pause': 'warn', | |
'playwright/no-skipped-test': 'warn', | |
'playwright/no-standalone-expect': 'error', | |
'playwright/no-unsafe-references': 'error', | |
'playwright/no-useless-await': 'warn', | |
'playwright/no-useless-not': 'warn', | |
'playwright/no-wait-for-navigation': 'error', | |
'playwright/no-wait-for-selector': 'warn', |
README.md#L120-L121
eslint-plugin-playwright/README.md
Lines 120 to 121 in 9374973
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | :-: | :-: | :-: | | |
| [consistent-spacing-between-blocks](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/consistent-spacing-between-blocks.md) | Enforce consistent spacing between test blocks | ✅ | 🔧 | | |
src/utils/test-expression.ts
Outdated
call.type === 'step' || | ||
call.type === 'hook' || | ||
(call.type === 'test' && methods.includes('test')) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Function Ignores Methods for Non-Test Calls
The isTestExpression
function incorrectly handles the methods
parameter. When methods
is provided, it unconditionally returns true
for step
and hook
call types, even if they are not included in the methods
array. It only correctly filters for test
call types.
as requested in review
but turn it off by default to be opt-in
and adopt logic from existing official rules, like [`newline-before-return`](https://github.com/eslint/eslint/blob/main/lib/rules/newline-before-return.js)
24a0d16
to
b3373f0
Compare
An ESLint rule that ensures consistent spacing between test blocks (e.g.
test
,test.step
,test.beforeEach
, etc.). This rule helps improve the readability and maintainability of test code by ensuring that test blocks are clearly separated from each other.Note
Adds a new rule to enforce a blank line between Playwright test blocks, with docs, tests, utils, and plugin export.
consistent-spacing-between-blocks
: enforces a blank line beforetest
,test.step
, hooks; auto-fixable; recommended; error messagemissingWhitespace
.src/rules/consistent-spacing-between-blocks.ts
; tests insrc/rules/consistent-spacing-between-blocks.test.ts
.src/utils/test-expression.ts
to unwrap and detect test-related expressions.src/index.ts
underrules
.docs/rules/consistent-spacing-between-blocks.md
with examples.README.md
rules table to includeconsistent-spacing-between-blocks
(✅, 🔧).Written by Cursor Bugbot for commit 9374973. This will update automatically on new commits. Configure here.