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

Some tokens are falsely labeled as broken #2340

Merged
merged 11 commits into from
Nov 29, 2023
1 change: 1 addition & 0 deletions src/app/components/Tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function Tokens({ isActive }: { isActive: boolean }) {
})),
[tokens, usedTokenSet, activeTokenSet],
);

const tokenType = useSelector(tokenTypeSelector);

const [error, setError] = React.useState<string | null>(null);
Expand Down
2 changes: 0 additions & 2 deletions src/utils/TokenResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ const output = [
value: 6,
},
{
failedToResolve: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? This token should be classified as failedToResolve because it did fail to resolve. We cant just remove this.

name: 'mathWrong',
rawValue: '{foo} * {boo}',
value: '3 * {baz}',
Expand Down Expand Up @@ -277,7 +276,6 @@ const output = [
value: '#ff0000',
},
{
failedToResolve: true,
name: 'spacing.xs',
rawValue: '{spacing.xs}',
value: '{spacing.xs}',
Expand Down
5 changes: 3 additions & 2 deletions src/utils/TokenResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TokenResolver {
this.tokenMap = new Map();
this.memo = new Map();
this.populateTokenMap();

return this.resolveTokenValues();
}

Expand Down Expand Up @@ -187,10 +188,10 @@ class TokenResolver {
}
} else {
// If it's not, we mark it as failed to resolve
six7 marked this conversation as resolved.
Show resolved Hide resolved
const hasFailingReferences = !AliasRegex.test(JSON.stringify(finalValue));
// const hasFailingReferences = !AliasRegex.test(JSON.stringify(finalValue));

resolvedToken = {
six7 marked this conversation as resolved.
Show resolved Hide resolved
...token, value: finalValue, rawValue: token.value, ...(hasFailingReferences ? { failedToResolve: true } : {}),
...token, value: finalValue, rawValue: token.value,
} as ResolveTokenValuesResult;
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/tokenHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ export function mergeTokenGroups(tokens: Record<string, SingleToken[]>, usedSets
});
}
});

return mergedTokens;
}
Loading