Skip to content

feat: add no-unknown-animations rule - #535

Open
Gaic4o wants to merge 1 commit into
eslint:mainfrom
Gaic4o:feat/no-unknown-animations
Open

feat: add no-unknown-animations rule#535
Gaic4o wants to merge 1 commit into
eslint:mainfrom
Gaic4o:feat/no-unknown-animations

Conversation

@Gaic4o

@Gaic4o Gaic4o commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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 is the purpose of this pull request?

This PR adds the no-unknown-animations rule to report animation names that don't match any @keyframes rule defined in the same source.

What changes did you make? (Give an overview)

  • Added the no-unknown-animations rule for animation and animation-name declarations.
  • Added tests and documentation for the new rule.

Related Issues

fixes #529

Disclosure: I'm a participant of open source contribution program OSSCA

// Helpers
//-----------------------------------------------------------------------------

const animationPropertyPattern = /^animation(?:-name)?$/iu;

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.

This should also check for vendored prefixes (e.g. -webkit-animation) as the @keyframes check also does.

/*
* If the value can't be matched against the property grammar,
* its animation name can't be determined reliably. This
* includes dynamic values such as var(). Invalid property

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.

I think the rule should support checking local resolvable var declarations.
There will be a helper for this but this rule could already check the default value of a var, e.g. "slide-in" in animation: var(--animation-name, "slide-in").

continue;
}

const name = getAnimationName(child);

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.

The name should not be null as the lexer already checks that it is a string or an identifier. Otherwise a test case for this is missing.

@DMartens DMartens moved this from Needs Triage to Implementing in Triage Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Implementing

Development

Successfully merging this pull request may close these issues.

New Rule: no-unknown-animations

2 participants