Skip to content

feat: add new rule no-duplicate-keyframe-selectors#143

Merged
nzakas merged 9 commits into
mainfrom
no-dup-keyframe-selectors
Jul 21, 2025
Merged

feat: add new rule no-duplicate-keyframe-selectors#143
nzakas merged 9 commits into
mainfrom
no-dup-keyframe-selectors

Conversation

@snitin315

Copy link
Copy Markdown
Contributor

Prerequisites checklist

What is the purpose of this pull request?

Add new rule no-duplicate-keyframe-selectors.

What changes did you make? (Give an overview)

Examples of incorrect code for this rule:

/* eslint css/no-duplicate-keyframe-selectors: "error" */

@keyframes test {
	0% {
		opacity: 0;
	}

	0% {
		opacity: 1;
	}
}

@keyframes test {
	from {
		opacity: 0;
	}

	from {
		opacity: 1;
	}
}

@keyframes test {
	from {
		opacity: 0;
	}

	from {
		opacity: 1;
	}
}

Examples of correct code for this rule:

/* eslint css/no-duplicate-keyframe-selectors: "error" */

@keyframes test {
	0% {
		opacity: 0;
	}

	100% {
		opacity: 1;
	}
}

@keyframes test {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

Related Issues

Fix #141

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

Comment thread eslint.config.js Outdated
export default [
{
ignores: ["**/tests/fixtures/", "**/dist/"],
ignores: ["**/tests/fixtures/", "**/dist/", "test.css"],

@snitin315 snitin315 May 21, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this test.css for local testing purposes, similar to the eslint repo

Screenshot 2025-05-22 at 12 41 02 AM

Comment thread src/rules/no-duplicate-keyframe-selectors.js Outdated
@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label May 22, 2025
@Tanujkanti4441 Tanujkanti4441 moved this from Needs Triage to Implementing in Triage May 22, 2025
@snitin315 snitin315 force-pushed the no-dup-keyframe-selectors branch from 62ec302 to 470e3a9 Compare May 31, 2025 17:26
@nzakas

nzakas commented Jun 3, 2025

Copy link
Copy Markdown
Member

@snitin315 can you check the merge conflicts?

Comment thread eslint.config.js
@snitin315

Copy link
Copy Markdown
Contributor Author

@nzakas resolved.

Comment thread eslint.config.js Outdated
{
files: ["**/*.css"],
language: "css/css",
...css.configs.recommended,

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.

can we use extends here instead?


create(context) {
return {
Atrule(node) {

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.

This method is traversing the at-rule itself instead of letting the rule do so.

It would be more efficient to do "Atrule[name=keyframes]", "Atrule[name=keyframes]:exit" and then look for the selectors in between.

See https://github.com/eslint/css/blob/main/src/rules/use-layers.js as an example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, done.

@TKDev7

TKDev7 commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

@snitin315 Are you still working on this?

@snitin315

Copy link
Copy Markdown
Contributor Author

Yes

@lumirlumir

Copy link
Copy Markdown
Member

Hi @snitin315,

There are a few merge conflicts. Whenever you have a chance, could you take a look?

@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 dfe9c05 into main Jul 21, 2025
22 checks passed
@nzakas nzakas deleted the no-dup-keyframe-selectors branch July 21, 2025 14:43
@github-project-automation github-project-automation Bot moved this from Implementing to Complete in Triage Jul 21, 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: no-duplicate-keyframe-selectors

5 participants