Skip to content

Commit

Permalink
animation-name with dash (-)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco committed Sep 18, 2020
1 parent bb2bcbb commit 74c8ba4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions build-system/eslint-rules/jss-animation-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,31 @@ module.exports = function (context) {
}
// Could be {key: val} identifier or {'key': val} string
const keyName = node.key.name || node.key.value;
if (keyName !== 'animationName' && keyName !== 'animation') {
const isAnimation = keyName === 'animation';
const isAnimationName =
keyName === 'animationName' || keyName === 'animation-name';
if (!isAnimationName && !isAnimation) {
return;
}
if (typeof node.value.value !== 'string') {
context.report({
node: node.value,
message:
`Use string literals for ${keyName} values.` +
(keyName === 'animation'
(isAnimation
? '\n(Independent animation-* properties (e.g. animation-delay) are exempt from this rule, except for animation-name.)'
: ''),
});
return;
}
if (
(keyName === 'animationName' && !/^\$/.test(node.value.value)) ||
(keyName === 'animation' && !/(^| )\$/.test(node.value.value))
(isAnimationName && !/^\$/.test(node.value.value)) ||
(isAnimation && !/(^| )\$/.test(node.value.value))
) {
context.report({
node: node.value,
message: `The animation name in property ${keyName} should start with $${
keyName === 'animationName' ? ` (e.g. $${node.value.value})` : ''
isAnimationName ? ` (e.g. $${node.value.value})` : ''
}.\nThis scopes it to a @keyframes rule present in this module.`,
});
}
Expand Down

0 comments on commit 74c8ba4

Please sign in to comment.