Skip to content

no-unused-class-names ignores cmkOptions.animation: false when counting animation-name references #439

Description

@mizdra

Summary

The no-unused-class-names rule (both @css-modules-kit/stylelint-plugin and @css-modules-kit/eslint-plugin) always treats tokens referenced by animation-name (and the animation shorthand) as "used", regardless of the cmkOptions.animation setting.

The rest of css-modules-kit (ts-plugin, codegen) extracts animation-name references only when animation is enabled. The rule should follow the same setting.

Reproduction

// tsconfig.json
{ "cmkOptions": { "animation": false } }
/* a.module.css */
.fade { color: red; }
.button { animation-name: fade; }
// a.tsx (uses styles.button only)

Expected: .fade is reported as unused. With animation: false, animation-name is not treated as a token reference.

Actual: .fade is not reported. findUsedTokenNames in @css-modules-kit/core walks animation-name / animation declarations unconditionally, so fade is counted as used.

Only false negatives (missed reports) occur, and only for users who explicitly set animation: false (the default is true).

Notes on fixing

The linter plugins currently do not read cmkOptions at all, so the fix needs a design decision about how they receive the option:

  • Accept it as a rule option (stylelint secondary options / ESLint rule options): idiomatic for linters, but duplicates the tsconfig setting
  • Read tsconfig from the plugins: keeps a single source of truth, but brings config discovery and caching concerns into the plugins

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions