Skip to content

Conversation

sethamus
Copy link
Contributor

@sethamus sethamus commented Sep 26, 2025

Prerequisites checklist

What did you do?

a {\r/* CR */\f/* FF */\n/* LF */\r\n/* CRLF */}

What did you expect to happen?

  • CSSSourceCode.lines returns the correct array of lines.
  • getLocFromIndex and getIndexFromLoc return correct line/column positions.

What actually happened?

Lines containing CR or FF were not split, causing incorrect line/column calculations.

What is the purpose of this pull request?

According to the CSS Syntax Module Level 3, CSS defines newline as one of:

  • Line Feed (\n)
  • Carriage Return + Line Feed (\r\n)
  • Carriage Return (\r)
  • Form Feed (\f)

CSSSourceCode previously only handled LF and CRLF correctly because it relied on the default lineEndingPattern from TextSourceCodeBase (/\r?\n/).

This PR ensures CSSSourceCode aligns with the CSS specification for newline handling.

What changes did you make? (Give an overview)

  • Updated CSSSourceCode to pass lineEndingPattern: /\r\n|[\r\n\f]/u to TextSourceCodeBase.
  • Added tests to verify correct behavior for LF, CRLF, CR, FF.

Related Issues

fixes #276

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

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Sep 26, 2025
@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Sep 26, 2025
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nzakas nzakas merged commit 2d0eec6 into eslint:main Sep 29, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this from Needs Triage to Complete in Triage Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contributor pool
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Bug: Update rules to handle all newline types
2 participants