Skip to content

Commit bfb5377

Browse files
authored
Early exit if target function isn't present (scss-replace-duration and scss-replace-easing) (Shopify#7979)
The current migrations would inject a migration comment when encountering any numeric operator in a style declaration. This change adds an early exit if the target Sass function ins't present in the declaration.
1 parent f94cf14 commit bfb5377

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.changeset/twenty-pumpkins-fry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris-migrator': patch
3+
---
4+
5+
Early exit if target function isn't present for the scss-replace-duration and scss-replace-easing migrations

polaris-migrator/src/migrations/scss-replace-duration/scss-replace-duration.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
createSassMigrator,
88
setNodeValue,
99
StopWalkingFunctionNodes,
10+
hasSassFunction,
1011
} from '../../utilities/sass';
1112
import {isKeyOf} from '../../utilities/type-guards';
1213

@@ -30,6 +31,8 @@ export default createSassMigrator(
3031
methods.walkDecls(root, (decl) => {
3132
const parsedValue = valueParser(decl.value);
3233

34+
if (!hasSassFunction(namespacedDuration, parsedValue)) return;
35+
3336
parsedValue.walk((node) => {
3437
if (isNumericOperator(node)) {
3538
methods.report({

polaris-migrator/src/migrations/scss-replace-easing/scss-replace-easing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
createSassMigrator,
88
setNodeValue,
99
StopWalkingFunctionNodes,
10+
hasSassFunction,
1011
} from '../../utilities/sass';
1112
import {isKeyOf} from '../../utilities/type-guards';
1213

@@ -29,6 +30,8 @@ export default createSassMigrator(
2930
methods.walkDecls(root, (decl) => {
3031
const parsedValue = valueParser(decl.value);
3132

33+
if (!hasSassFunction(namespacedEasing, parsedValue)) return;
34+
3235
parsedValue.walk((node) => {
3336
if (isNumericOperator(node)) {
3437
methods.report({

0 commit comments

Comments
 (0)