Skip to content

feat: add selector-complexity rule#252

Merged
nzakas merged 6 commits into
eslint:mainfrom
Tanujkanti4441:selector-comp-rule
Oct 8, 2025
Merged

feat: add selector-complexity rule#252
nzakas merged 6 commits into
eslint:mainfrom
Tanujkanti4441:selector-comp-rule

Conversation

@Tanujkanti4441

@Tanujkanti4441 Tanujkanti4441 commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Prerequisites checklist

What is the purpose of this pull request?

To add a new rule to limit CSS selectors.

What changes did you make? (Give an overview)

Added a new rule called selector-complexity with following options:

maxIds
maxClasses
maxTypes
maxAttributes
maxPseudoClasses
maxUniversals
maxCompounds
maxCombinators
disallowCombinators
disallowPseudoClasses
disallowPseudoElements
disallowAttributes
disallowAttributeMatchers

Related Issues

Fixes #19

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 3, 2025
@eslint-github-bot eslint-github-bot Bot mentioned this pull request Sep 3, 2025
1 task
@Tanujkanti4441 Tanujkanti4441 marked this pull request as ready for review September 7, 2025 17:37
@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label Sep 8, 2025
@fasttime fasttime moved this from Needs Triage to Implementing in Triage Sep 16, 2025

@fasttime fasttime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Excited to see this rule taking shape. I noticed that currently the rule only reports on a single node in the selector:

Image

This is different from Stylelint, which reports on the whole selector (#foo #bar #baz) when a it finds a problem:

Stylelint Demo

I believe that reporting on the whole selector would be less confusing because it's not obvious which part of a selector should be changed to comply with the rule. Thoughts?

Comment thread src/rules/selector-complexity.js Outdated
Comment thread src/rules/selector-complexity.js
Comment thread src/rules/selector-complexity.js
Comment thread src/rules/selector-complexity.js
Comment thread src/rules/selector-complexity.js
Comment thread src/rules/selector-complexity.js
Comment thread src/rules/selector-complexity.js
Comment thread src/rules/selector-complexity.js Outdated
Comment thread src/rules/selector-complexity.js Outdated

@fasttime fasttime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks! Leaving open for a second review before merging.

@fasttime fasttime moved this from Implementing to Second Review Needed in Triage Oct 1, 2025

@nzakas nzakas left a comment

Copy link
Copy Markdown
Member

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 2bd29c4 into eslint:main Oct 8, 2025
22 checks passed
@github-project-automation github-project-automation Bot moved this from Second Review Needed to Complete in Triage Oct 8, 2025
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 feature

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

New Rule: selector-complexity

4 participants