Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support animation names #86

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/files/animationName.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Used in `className`
@keyframes animationName1 {}

// Used in other classes
@keyframes animationName2 {}

.classUsingAnimation1 {
animation-name: animationName2;
}

// Using undefined animation name in another class
.classUsingAnimation2 {
animation-name: undefinedAnimationName;
}
Empty file.
39 changes: 39 additions & 0 deletions test/lib/rules/no-undef-class.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,4 +566,43 @@ describe('no-undef-class', function () {
},
].map((testCase) => addFilenameOption(testCase)),
});

ruleTester.run('no-undef-class', rule, {
valid: [],
invalid: [
{
name: 'should support animation identifiers - using undefinedAnimationName in className',
code: `
import s from 'test/files/animationName.scss';

export default Foo = () => (
<div>
<div className={s.classUsingAnimation1}></div>
<div className={s.classUsingAnimation2}></div>
<div className={s.undefinedAnimationName}></div>
</div>
);
`,
errors: [
"Class or exported property 'undefinedAnimationName' not found",
],
},
{
name: 'should support animation identifiers - using undefinedAnimationName in another class',
code: `
import s from 'test/files/animationName.scss';

export default Foo = () => (
<div>
<div className={s.classUsingAnimation1}></div>
<div className={s.classUsingAnimation2}></div>
</div>
);
`,
errors: [
"Class or exported property 'undefinedAnimationName' not found",
],
},
].map((testCase) => addFilenameOption(testCase)),
});
});
35 changes: 35 additions & 0 deletions test/lib/rules/no-unused-class.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,39 @@ describe('no-unused-class', function () {
},
].map((testCase) => addFilenameOption(testCase)),
});

ruleTester.run('no-unused-class', rule, {
valid: [
{
name: 'should support animation identifiers - animationName1 used in className, animationName2 used in other classes',
code: `
import s from 'test/files/animationName.scss';

export default Foo = () => (
<div>
<div className={s.classUsingAnimation1}></div>
<div className={s.classUsingAnimation2}></div>
<div className={s.animationName1}></div>
</div>
);
`,
},
],
invalid: [
{
name: 'should support animation identifiers - animationName1 not used, animationName2 used in other classes',
code: `
import s from 'test/files/animationName.scss';

export default Foo = () => (
<div>
<div className={s.classUsingAnimation1}></div>
<div className={s.classUsingAnimation2}></div>
</div>
);
`,
errors: ['Unused classes found in animationName.scss: animationName1'],
},
].map((testCase) => addFilenameOption(testCase)),
});
});