Styledictionary/4/Hook Api Parsers

1.0.0Last update Oct 7, 2024
by@manishjha-04

This codemod updates registered parsers to be placed inside the hooks.parsers property, instead of parser, with a shift from the singular to the plural form. Registered parsers now apply globally without needing explicit application in the config. Additionally, the parse function has been renamed to parser for consistency.

Before

export default {
// register it inline or by SD.registerPreprocessor
parsers: [
{
pattern: /\.json5$/,
parse: ({ contents, filePath }) => {
return JSON5.parse(contents);
},
},
],
};

After

export default {
// register it inline or by SD.registerPreprocessor
parsers: ['json5-parser'],
hooks: {
parsers: {
name: 'json5-parser',
pattern: /\.json5$/,
parser: ({ contents, filePath }) => {
return JSON5.parse(contents);
},
},
},
};

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now