Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 5, 2022
1 parent 0561a62 commit d6c4361
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/config/plugin/lib/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const normalizePluginConfigTop = async function (
const locationName =
typeof pluginConfig === 'string' ? name : `${name}.${pluginProp}`
const { [pluginProp]: originalLocation, ...pluginConfigA } =
await safeNormalizeConfig(pluginConfig, [normalizeTop], {
await safeNormalizeConfig(pluginConfig, topRules, {
all: { cwd, prefix, parent: name, context: { pluginProp, builtins } },
keywords,
InputErrorType: ConsumerError,
Expand All @@ -22,15 +22,17 @@ export const normalizePluginConfigTop = async function (
return { originalLocation, pluginConfig: pluginConfigA, locationName }
}

const normalizeTop = {
name: '.',
required: true,
schema: {
type: ['string', 'object'],
errorMessage: 'must be a string or a plain object',
const topRules = [
{
name: '.',
required: true,
schema: {
type: ['string', 'object'],
errorMessage: 'must be a string or a plain object',
},
example: getExampleLocation,
transform(value, { context: { pluginProp } }) {
return normalizeObjectOrString(value, pluginProp)
},
},
example: getExampleLocation,
transform(value, { context: { pluginProp } }) {
return normalizeObjectOrString(value, pluginProp)
},
}
]

0 comments on commit d6c4361

Please sign in to comment.