Skip to lesson
Exit
Scoping project rules1 / 1

2 min lesson

Limit an icon rule to components

Scope one icon rule to component files, then test a matching and nonmatching task.

Check your understanding

Complete the practice "Limit an icon rule to component files".

Outcome: The rule loads for Card.tsx and stays out of the fixture task. Each diff follows the instruction set that actually applied.

Limit an icon rule to component files
Apply to Specific Files with one glob
SayThe icon import instruction belongs in src/components/*/.tsx, but the rule uses Always Apply and reaches unrelated fixtures and stories.
DoOpen .cursor/rules/component-icons.mdc and remove the always-on scope.
Type--- globs: src/components/**/*.tsx alwaysApply: false ---
SeeCursor treats the rule as Apply to Specific Files. It attaches when a matching component file enters context.
TypeImport icons from @/components/icon. Do not import from lucide-react in component files.
SeeThe body names one behavior and one boundary. No description is needed for the file glob scope.
DoCheck other rules whose globs match src/components and remove any contradictory icon instruction.
SeeEvery applicable rule now points to the same import path.
DoRun a fresh edit in src/components/Card.tsx, then one in src/test-fixtures/IconFixture.tsx.
SeeThe rule loads for Card.tsx and stays out of the fixture task. Each diff follows the instruction set that actually applied.
Learn more

Optional practice

Test yourself on Limit an icon rule to components

QWhich result proves the Project Rule has the intended scope?

Finish the check to continue.