Skip to content

feat: add suggestions to no-empty-blocks - #479

Open
k-yle wants to merge 1 commit into
eslint:mainfrom
k-yle:kh/autofix-empty-blocks
Open

feat: add suggestions to no-empty-blocks#479
k-yle wants to merge 1 commit into
eslint:mainfrom
k-yle:kh/autofix-empty-blocks

Conversation

@k-yle

@k-yle k-yle commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

Add sugggestions to no-empty-blocks. There are two different cases:

  • @layer name {} becomes @layer name
  • all other empty blocks like a {} become . This included unnamed layers such as @layer {}.

What changes did you make? (Give an overview)

Related Issues

Closes #476

Is there anything you'd like reviewers to focus on?

Comment thread src/rules/no-empty-blocks.js Outdated
Comment thread src/rules/no-empty-blocks.js Outdated
@DMartens DMartens moved this from Needs Triage to Second Review Needed in Triage Jun 28, 2026
@DMartens

Copy link
Copy Markdown
Contributor

Thank you for the PR. Just found two small refactorings using more appropriate methods.
Also checked and tried ways to create a parse error / changing AST after removal but could not find one.
Would like the second reviewer to focus on this.

@k-yle
k-yle force-pushed the kh/autofix-empty-blocks branch from 7790a62 to a91126c Compare June 29, 2026 12:38
Comment thread src/rules/no-empty-blocks.js Outdated
Comment thread src/rules/no-empty-blocks.js Outdated
@k-yle
k-yle force-pushed the kh/autofix-empty-blocks branch from a91126c to 9c140f5 Compare July 8, 2026 11:27
@k-yle
k-yle requested a review from Pixel998 July 8, 2026 11:29
Comment thread src/rules/no-empty-blocks.js Outdated
Comment thread src/rules/no-empty-blocks.js Outdated
{
messageId: "convertToStatement",
fix: fixer =>
fixer.replaceText(node, ";"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixer currently only replaces the block node, which preserves any whitespace before {} and can produce output like @layer foo ;. Could we include the preceding whitespace in the replacement range so the fix produces @layer foo;?

@k-yle k-yle Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, i did indeed lose track of this PR.

I did this using node.prelude.loc.end...node.loc.end, not sure if there's a more idiomatic solution

@github-actions

Copy link
Copy Markdown
Contributor

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions Bot added the Stale label Jul 25, 2026
@k-yle
k-yle force-pushed the kh/autofix-empty-blocks branch from 9c140f5 to d70549d Compare July 27, 2026 12:24
@github-actions github-actions Bot removed the Stale label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Second Review Needed

Development

Successfully merging this pull request may close these issues.

Rule Change: autofix for no-empty-blocks

3 participants