Skip to content

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

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

fix: recognize CSS whitespace in named grid areas#556
KumJungMin wants to merge 1 commit 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 validation of CSS grid-area definitions with tabs, newlines, spaces, and consecutive whitespace.
    • Correctly identifies uneven grid rows when tab separators are used.
  • 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: 3c7bc40d-083e-4005-8301-86bf97fe6f9d

📥 Commits

Reviewing files that changed from the base of the PR and between 510403e and d9279fe.

📒 Files selected for processing (2)
  • src/rules/no-invalid-named-grid-areas.js
  • tests/rules/no-invalid-named-grid-areas.test.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, newlines, spaces, and repeated whitespace as cell separators. Tests cover valid mixed whitespace and invalid uneven rows.

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 CSS whitespace sequences. Tests cover tab-separated cells, mixed separators, and uneven row lengths.

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

Merge Risk: ⚪ Minimal · up to d9279

This localized change makes named grid areas recognize tabs, line feeds, and spaces as CSS whitespace without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #537 by splitting grid-area rows on CSS whitespace, including tabs, and add regression tests for tab-separated and uneven rows.
Out of Scope Changes check ✅ Passed The pull request only changes the affected rule and its related tests. 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…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: recognizing CSS whitespace when parsing named grid areas.
Full details: Docstring Coverage

Explanation

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 files.

✨ 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)

@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
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