Skip to content

fix: report each disallowed attribute location in selector-complexity - #580

Open
Pixel998 wants to merge 1 commit into
mainfrom
fix/selector-complexity-disallow-attributes-location
Open

Pixel998 wants to merge 1 commit into
mainfrom
fix/selector-complexity-disallow-attributes-location

Conversation

@Pixel998

@Pixel998 Pixel998 commented Sep 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 did you do?

/* eslint css/selector-complexity: ["error", { "disallowAttributes": ["data-foo"] }] */

[data-foo] .item[data-foo] {}

What did you expect to happen?

Two errors, one at each data-foo attribute selector.

What actually happened?

Two errors, both reported at 3:2.

What is the purpose of this pull request?

This PR makes selector-complexity report each disallowed attribute selector at its own location when the same attribute appears more than once in a selector.

What changes did you make? (Give an overview)

The disallowAttributes check now iterates the attribute selector nodes directly and reports at each node's name.loc, instead of mapping to names and looking the location up with find().

Related Issues

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

Summary by CodeRabbit

  • Bug Fixes
    • Disallowed attributes are now reported individually, with each error pointing to the correct attribute—even when the same attribute appears multiple times or in different selector compounds.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Sep 27, 2026
@eslint-github-bot eslint-github-bot Bot added the bug Something isn't working label Sep 27, 2026
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8bf66604-df83-403c-8d16-dc0092bf4336

📥 Commits

Reviewing files that changed from the base of the PR and between 4475991 and a6d4257.

📒 Files selected for processing (2)
  • src/rules/selector-complexity.js
  • tests/rules/selector-complexity.test.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The selector-complexity rule now reports each disallowed attribute occurrence at its own name location. Tests cover repeated attributes and attributes in separate selector compounds.

Changes

Disallowed attribute reporting

Layer / File(s) Summary
Report each disallowed attribute occurrence
src/rules/selector-complexity.js, tests/rules/selector-complexity.test.js
The rule checks disallowed attributes on selector nodes and reports each match at that node’s name. Tests cover repeated data-foo, alt, and href attributes.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to a6d42

The change gives repeated disallowed attributes diagnostics at their respective locations, and the added tests assert those ranges. No actionable merge-blocking risk remains from the inspected changes.

🚥 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 and concisely describes the main change: reporting each disallowed attribute location in selector-complexity.
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…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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: Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant