Skip to content

fix: crash in no-important on non-standard important values - #541

Draft
Pixel998 wants to merge 1 commit into
mainfrom
fix/no-important-crash
Draft

fix: crash in no-important on non-standard important values#541
Pixel998 wants to merge 1 commit into
mainfrom
fix/no-important-crash

Conversation

@Pixel998

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 did you do?

/* eslint css/no-important: "error" */
a { color: red !ie; }

What did you expect to happen?

No error. !ie is a non-standard hack, not an !important flag.

What actually happened?

TypeError: Cannot read properties of null (reading 'index')

What is the purpose of this pull request?

This PR fixes the crash above. important holds the raw identifier for hacks like !ie, which is truthy, so the rule went on to locate the flag in the source text, found no match, and dereferenced null.

What changes did you make? (Give an overview)

Narrowed the check to important === true, so only real !important flags are reported.

Depends on eslint/csstree#152, which makes !IMPORTANT parse as true.

Related Issues

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

@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Aug 24, 2026
@eslint-github-bot eslint-github-bot Bot added the bug Something isn't working label Aug 24, 2026
@Pixel998 Pixel998 moved this from Needs Triage to Blocked in Triage Aug 24, 2026

@DMartens DMartens left a comment

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.

Changes make sense to me, thanks. Marking as approved waiting for the csstree PR to land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Blocked

Development

Successfully merging this pull request may close these issues.

2 participants