Skip to content

Commit c9eea8d

Browse files
le0nikKent C. Dodds
authored andcommitted
fix(devtool): allow false as devtool value (#128)
1 parent ac9fad9 commit c9eea8d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/properties/devtool/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const DEVTOOL_REGEX = new RegExp(
2222
`(${options.join('$|')})` // one of the options
2323
)
2424

25-
export default Joi
26-
.string()
27-
.regex(DEVTOOL_REGEX)
25+
export default [
26+
Joi.string().regex(DEVTOOL_REGEX),
27+
Joi.any().valid(false),
28+
]

src/properties/devtool/index.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ const validModuleConfigs = [
1111
{ input: 'eval-source-map' },
1212
{ input: 'cheap-source-map' },
1313
{ input: 'hidden-source-map' },
14+
{ input: false },
1415
]
1516

1617
const invalidModuleConfigs = [
1718
{ input: 'foo', error: { } },
1819
{ input: 'eval-source-map-foo', error: { } },
1920
{ input: 'foo-cheap-source-map', error: { } },
2021
{ input: '#@eval-foo', error: { } },
22+
{ input: 'false', error: { } },
23+
{ input: true, error: { } },
2124
]
2225

2326
describe('devtool', () => {

test/utils/allValid.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import validate from '../../src'
77
*/
88
export default (configs, schema) => {
99
configs.forEach((input) => {
10-
const { input: validConfig, schema: schemaOverride } = input
11-
if (!validConfig) {
10+
if (!Object.prototype.hasOwnProperty.call(input, 'input')) {
1211
throw new Error(
1312
'Please supply the valid config object like `{ input: <valid-config-object> }`.' +
1413
`You passed ${JSON.stringify(input)}`
1514
)
1615
}
1716

17+
const { input: validConfig, schema: schemaOverride } = input
18+
1819
it(`: ${chalk.gray(util.inspect(validConfig, false, null))} should be valid`, () => {
1920
const result = validate(validConfig, {
2021
schema: schemaOverride || schema,

0 commit comments

Comments
 (0)