registerParser({ name: 'foo', pattern: /\.json$/g, parser: () => {} }); // add name prop, parse -> parser
registerPreprocessor({ name: 'foo', preprocessor: () => {} }); // no change
registerTransform({ name: 'foo', type: 'name', transform: () => {} }); // transformer -> transform
registerTransformGroup({ name: 'foo', transforms: [] }); // no change
registerFormat({ name: 'foo', format: () => {} }); // formatter -> format
registerFilter({ name: 'foo', filter: () => {} }); // no change
registerFileHeader({ name: 'foo', fileHeader: () => {} }); // no change
registerAction({ name: 'foo', do: () => {}, undo: () => {} }); // no change
hooks.parsers = {}; // scoped to hooks object & changed to keyed object
hooks.preprocessors = {}; // scoped to hooks object
hooks.transforms = {}; // scoped to hooks object & changed to plural
hooks.transformGroups = {}; // scoped to hooks object & changed to plural
hooks.formats = {}; // scoped to hooks object & changed to plural
hooks.filters = {}; // scoped to hooks object & changed to plural
hooks.fileHeaders = {}; // scoped to hooks object & changed to plural
hooks.actions = {}; // scoped to hooks object & changed to plural
Also, registered parsers don't just run by default because they're registered, for consistency sake you should apply parsers on the global config level by name, the same way all other hooks are applied:
export default {
hooks: {
// inline definition of php parser as alternative to `registerParser` method
parsers: {
"php-parser": {
pattern: /\.php$/,
parse: ({ filePath, contents }) => {
return parse(contents);
},
},
},
},
source: [
"**/*.tokens.json"
],
// applying the parser to this dictionary config
parsers: ["php-parser"]
}
Our APIs for registering custom things should be more consistent, it's currently quite confusing and easy to make mistakes due to lack of consistency.
Before:
After:
Also, registered parsers don't just run by default because they're registered, for consistency sake you should apply parsers on the global config level by name, the same way all other hooks are applied: