Skip to content

fix: recognize CSS whitespace in named grid areas - #556

Open
KumJungMin wants to merge 3 commits into
eslint:mainfrom
KumJungMin:fix/537-grid-template-areas-whitespace
Open

fix: recognize CSS whitespace in named grid areas#556
KumJungMin wants to merge 3 commits into
eslint:mainfrom
KumJungMin:fix/537-grid-template-areas-whitespace

Conversation

@KumJungMin

@KumJungMin KumJungMin commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Disclosure: I'm a participant of open source contribution program OSSCA

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?

  • This PR fixes a false positive that occurs when tabs are used as cell token separators in grid-template-areas.
  • According to the CSS Grid specification, consecutive CSS whitespace characters separate cell tokens.
  • However, the existing implementation only splits strings on literal spaces (U+0020), causing valid CSS containing tabs to report an unevenGridArea error.
.grid {
    grid-template-areas:
        "a	b"
        "a b";
}

What changes did you make? (Give an overview)

  • Added the /[\t\n ]+/u regular expression to match sequences of CSS whitespace.
  • Updated grid-template-areas rows to split on CSS whitespace instead of literal spaces.
  • Added regression tests covering tabs and combinations of tabs and spaces.
  • Used the explicitly defined CSS whitespace characters(tabs, line feeds, and spaces)
  • The regular expression was also tested using RegExr.

Related Issues

fixes #537

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved CSS grid-area validation for tabs, spaces, and consecutive whitespace between area names.
    • Correctly identifies uneven grid rows when tabs are used as separators.
    • Newline-separated tokens are no longer interpreted as whitespace by the validator.
  • Tests

    • Added coverage for valid tab-separated grid-area names.
    • Added coverage for invalid uneven rows using tabs.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: bc41f77b-780a-4d04-9ff4-d7884c5336c0

📥 Commits

Reviewing files that changed from the base of the PR and between d9279fe and 4fe7b74.

📒 Files selected for processing (1)
  • src/rules/no-invalid-named-grid-areas.js

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The grid-area rule now treats tabs and repeated spaces as separators between cell tokens. Tests cover mixed separators and uneven rows with tab-separated cells.

Changes

Grid Area Whitespace Handling

Layer / File(s) Summary
CSS whitespace tokenization and validation
src/rules/no-invalid-named-grid-areas.js, tests/rules/no-invalid-named-grid-areas.test.js
The parser splits grid-area rows on consecutive tabs and spaces. Tests cover valid mixed whitespace and invalid uneven rows.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 4fe7b

The grid-area parser now accepts tab and repeated-space separators, preventing false uneven-cell-count reports for valid templates. No current merge-readiness risk remains.

Suggested reviewers: pixel998

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: recognizing CSS whitespace in named grid areas.
Linked Issues check ✅ Passed The changes address issue #537 by parsing tabs and spaces as separators between grid-area cell tokens. The added tests cover tab-separated valid rows and uneven rows with tabs.
Out of Scope Changes check ✅ Passed All changes are limited to the grid-area parser and regression tests required by issue #537. No unrelated changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

/**
* Regular expression to match sequences of CSS whitespace
*/
const cssWhitespace = /[\t\n ]+/u;

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.

Suggested change
const cssWhitespace = /[\t\n ]+/u;
const cssWhitespace = /[\t ]+/u;

CSS in general allows newlines as whitespace but not inside strings (Example)

@KumJungMin KumJungMin Sep 6, 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.

Thanks for pointing this out :) (https://regexr.com/8ocse)

I've removed \n from the pattern. ea057db

@DMartens DMartens moved this from Needs Triage to Implementing in Triage Sep 2, 2026
@DMartens DMartens added the accepted There is consensus among the team that this change meets the criteria for inclusion label Sep 2, 2026
@KumJungMin
KumJungMin requested a review from DMartens September 6, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion bug Something isn't working

Projects

Status: Implementing

Development

Successfully merging this pull request may close these issues.

Bug: no-invalid-named-grid-areas does not recognize tabs as whitespace between cell tokens

2 participants