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
Fix false positives for interpolation in keyframes-name-pattern #6265
Changes from 2 commits
a99d195
e428746
657352d
685ba22
8d2fd35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,51 @@ | ||||||
'use strict'; | ||||||
|
||||||
const isStandardSyntaxKeyframesName = require('../isStandardSyntaxKeyframesName'); | ||||||
|
||||||
describe('isStandardSyntaxKeyframesName', () => { | ||||||
it('standard name', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes slidein {}')).toBeTruthy(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
As the util is checking the keyframes-name, and not the whole We'll need to update the other tests too. |
||||||
}); | ||||||
it('hyphenated name', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes slide-in {}')).toBeTruthy(); | ||||||
}); | ||||||
it('name with underscore', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes slide_in {}')).toBeTruthy(); | ||||||
}); | ||||||
it('scss interpolation', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes frame-#{$name} {}')).toBeFalsy(); | ||||||
}); | ||||||
it('scss interpolation start', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes #{$name}-frame {}')).toBeFalsy(); | ||||||
}); | ||||||
it('scss interpolation single quoted', () => { | ||||||
expect(isStandardSyntaxKeyframesName("@keyframes 'frame-#{$name}' {}")).toBeFalsy(); | ||||||
}); | ||||||
it('scss interpolation single quoted start', () => { | ||||||
expect(isStandardSyntaxKeyframesName("@keyframes '#{$name}-frame' {}")).toBeFalsy(); | ||||||
}); | ||||||
it('scss interpolation double quoted', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes "frame-#{$name}" {}')).toBeFalsy(); | ||||||
}); | ||||||
it('scss interpolation doubled quoted start', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes "#{$name}-frame" {}')).toBeFalsy(); | ||||||
}); | ||||||
it('less interpolation', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes frame-@{name} {}')).toBeFalsy(); | ||||||
}); | ||||||
it('less interpolation start', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes @{name}-frame {}')).toBeFalsy(); | ||||||
}); | ||||||
it('less interpolation single quoted', () => { | ||||||
expect(isStandardSyntaxKeyframesName("@keyframes 'frame-@{name}' {}")).toBeFalsy(); | ||||||
}); | ||||||
it('less interpolation single quoted start', () => { | ||||||
expect(isStandardSyntaxKeyframesName("@keyframes '@{name}-frame {}' {}")).toBeFalsy(); | ||||||
}); | ||||||
it('less interpolation double quoted', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes "frame-@{name}" {}')).toBeFalsy(); | ||||||
}); | ||||||
it('less interpolation doubled quoted start', () => { | ||||||
expect(isStandardSyntaxKeyframesName('@keyframes "@{name}-frame" {}')).toBeFalsy(); | ||||||
}); | ||||||
}); |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||
'use strict'; | ||||
|
||||
const hasInterpolation = require('./hasInterpolation'); | ||||
|
||||
/** | ||||
* Check whether a keyframes name is standard | ||||
* | ||||
* @param {string} keyframesName | ||||
* @returns {boolean} | ||||
*/ | ||||
|
||||
ybiquitous marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
module.exports = function (keyframesName) { | ||||
ybiquitous marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
// SCSS or Less interpolation | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We can lose the comment. (The |
||||
if (hasInterpolation(keyframesName)) { | ||||
return false; | ||||
} | ||||
|
||||
return true; | ||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to before the first conditionally as we normally check that things are standard before any other operation.