diff --git a/test/files/animationName.scss b/test/files/animationName.scss new file mode 100644 index 0000000..edbf73d --- /dev/null +++ b/test/files/animationName.scss @@ -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; +} \ No newline at end of file diff --git a/test/lib/rules/multiple-import.test.js b/test/lib/rules/multiple-import.test.js new file mode 100644 index 0000000..e69de29 diff --git a/test/lib/rules/no-undef-class.test.js b/test/lib/rules/no-undef-class.test.js index f3e90a1..f138d3c 100644 --- a/test/lib/rules/no-undef-class.test.js +++ b/test/lib/rules/no-undef-class.test.js @@ -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 = () => ( +
+
+
+
+
+ ); + `, + 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 = () => ( +
+
+
+
+ ); + `, + errors: [ + "Class or exported property 'undefinedAnimationName' not found", + ], + }, + ].map((testCase) => addFilenameOption(testCase)), + }); }); diff --git a/test/lib/rules/no-unused-class.test.js b/test/lib/rules/no-unused-class.test.js index bd53a45..8328bc3 100644 --- a/test/lib/rules/no-unused-class.test.js +++ b/test/lib/rules/no-unused-class.test.js @@ -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 = () => ( +
+
+
+
+
+ ); + `, + }, + ], + 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 = () => ( +
+
+
+
+ ); + `, + errors: ['Unused classes found in animationName.scss: animationName1'], + }, + ].map((testCase) => addFilenameOption(testCase)), + }); });