Registry
A

color-token-to-hex-object-js-ts

No description available

alexbit-codemod1 executions

  • Legacy
  • design tokens
Connect a repo
npx codemod color-token-to-hex-object-js-ts

In JS/TS files, for tokens of the type 'color' (not other tokens), transform $value into an object with a 'hex' key, where the value remains the same as the previous $value

Before

ts
const tokens = {
  interactive: {
    '100': {
      $value: '<some string>',
      $type: 'color',
    },
  },
  someOtherColorToken: {
    $value: '#DBF0FF',
    $type: 'color',
  },
};

After

ts
const tokens = {
  interactive: {
    '100': {
      $value: { hex: '<some string>' },
      $type: 'color',
    },
  },
  someOtherColorToken: {
    $value: { hex: '#DBF0FF' },
    $type: 'color',
  },
};

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.