Skip to content

Commit

Permalink
fix lintint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Feb 6, 2025
1 parent a209472 commit ec30523
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/validateTokenJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ if (getFlag('--silent') === null) {
// eslint-disable-next-line no-console
console.log(`\u001b[36;1m\u001b[1m${fail.fileName}\u001b[0m`)

for (const path of Object.keys(fail.errorsByPath)) {
for (const mainPath of Object.keys(fail.errorsByPath)) {
// eslint-disable-next-line no-console
console.log(`\nPath: \u001b[34;1m\u001b[1m${path}\u001b[0m`)
console.log(`\nPath: \u001b[34;1m\u001b[1m${mainPath}\u001b[0m`)
// eslint-disable-next-line no-console
console.log(
fail.errorsByPath[path]
fail.errorsByPath[mainPath]
.map(
({message, code, errors}) =>
`${message.replace(/\*\*(.*?)\*\*/g, '- \u001b[31;1m\u001b[1m$1\u001b[0m').replace(/\n(?!-)/g, '\n ↳ ')}, code: ${code}, errors:\n ${errors
({message, code, errors, ...item}) =>
`${message.replace(/\*\*(.*?)\*\*/g, '- \u001b[31;1m\u001b[1m$1\u001b[0m').replace(/\n(?!-)/g, '\n ↳ ')}, code: ${code}, path: ${item.path}, errors:\n ${errors
.map(error => {
return `- ${error.issues[0].code}: ${error.issues[0].message}`
})
Expand Down
32 changes: 32 additions & 0 deletions src/schemas/shadowToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export const shadowValue = z
})
.strict()

const baseShadowToken = baseToken.extend({
$value: z.union([shadowValue, referenceValue, z.array(shadowValue)]),
})

const override = z.union([referenceValue, baseShadowToken]).optional()

export const shadowToken = baseToken
.extend({
$value: z.union([shadowValue, z.array(shadowValue), referenceValue]),
Expand All @@ -42,6 +48,32 @@ export const shadowToken = baseToken
group: z.string().optional(),
})
.strict(),
'org.primer.overrides': z
.object(
{
light: override,
'light-tritanopia': override,
'light-protanopia-deuteranopia': override,
'light-high-contrast': override,
dark: override,
'dark-tritanopia': override,
'dark-protanopia-deuteranopia': override,
'dark-high-contrast': override,
'dark-dimmed': override,
},
{
errorMap: e => {
if (e.code === 'unrecognized_keys') {
return {
message: `Unrecognized key: "${e.keys.join(', ')}", must be one of: light, light-tritanopia, light-protanopia-deuteranopia, light-high-contrast, dark, dark-tritanopia, dark-protanopia-deuteranopia, dark-high-contrast, dark-dimmed`,
}
}
return {message: `Error: ${e.code}`}
},
},
)
.strict()
.optional(),
})
.optional(),
})
Expand Down
2 changes: 2 additions & 0 deletions src/tokens/functional/shadow/shadow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@
],
$type: 'shadow',
$extensions: {
'org.primer.figma': {
},
'org.primer.overrides': {
dark: {
$value: [
Expand Down

0 comments on commit ec30523

Please sign in to comment.