Skip to content

Commit

Permalink
Revert "Do not allow id string shortcut anymore"
Browse files Browse the repository at this point in the history
This reverts commit c9a9eba.
  • Loading branch information
ehmicky committed Feb 21, 2022
1 parent 292fc49 commit ce27735
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/config/normalize/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ export const normalizeOptionalArray = function (value = []) {
export const normalizeNumberString = function (value) {
return typeof value === 'number' ? String(value) : value
}

// Some object properties are have a string shortcut property.
// This normalizes them.
export const normalizeObjectOrString = function (value, propName) {
return typeof value === 'string' ? { [propName]: value } : value
}
7 changes: 5 additions & 2 deletions src/config/plugin/lib/item.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { normalizeObjectOrString } from '../../normalize/transform.js'
import {
validateObject,
validateObjectOrString,
validateJson,
} from '../../normalize/validate/complex.js'
Expand Down Expand Up @@ -39,9 +39,12 @@ const getFirstItem = function (stringArray) {

const normalizeItem = {
validate(value) {
validateObject(value)
validateObjectOrString(value)
validateJson(value)
},
transform(value, { context: { pluginProp } }) {
return normalizeObjectOrString(value, pluginProp)
},
}

const normalizeItemModuleId = {
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin/lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const normalizeList = async function ({
pluginConfigsB,
getListItemsDefinitions(pluginProp, defaultValue, builtins),
{
context: { builtins, modulePrefix },
context: { builtins, pluginProp, modulePrefix },
cwd,
prefix: `${name}.`,
UserErrorType: ConsumerError,
Expand Down

0 comments on commit ce27735

Please sign in to comment.