Skip to content

Commit f2ad501

Browse files
committed
Fix: pretty-format → q-i
1 parent 153c7db commit f2ad501

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

bin/styleguidist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const minimist = require('minimist');
66
const chalk = require('chalk');
7-
const prettyFormat = require('pretty-format');
7+
const stringify = require('q-i').stringify;
88
const logger = require('glogg')('rsg');
99
const getConfig = require('../scripts/config');
1010
const setupLogger = require('../scripts/logger');
@@ -228,5 +228,5 @@ function printNoLoaderError(errors) {
228228
}
229229

230230
function verbose(header, object) {
231-
logger.debug(chalk.bold(header) + '\n' + prettyFormat(object));
231+
logger.debug(chalk.bold(header) + '\n\n' + stringify(object));
232232
}

package-lock.json

Lines changed: 25 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"lowercase-keys": "^1.0.0",
6868
"markdown-to-jsx": "^5.4.2",
6969
"minimist": "^1.2.0",
70-
"pretty-format": "^20.0.3",
7170
"prop-types": "^15.5.10",
71+
"q-i": "^1.1.1",
7272
"react-codemirror2": "1.0.0",
7373
"react-dev-utils": "^3.0.2",
7474
"react-docgen": "^3.0.0-beta7",

scripts/utils/sanitizeConfig.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ const map = require('lodash/map');
1313
const listify = require('listify');
1414
const chalk = require('chalk');
1515
const leven = require('leven');
16-
const prettyFormat = require('pretty-format');
16+
const stringify = require('q-i').stringify;
1717
const typeDetect = require('type-detect');
1818
const logger = require('glogg')('rsg');
1919
const StyleguidistError = require('./error');
2020

21-
const format = value => prettyFormat(value, { min: true });
22-
2321
const typeCheckers = {
2422
number: isFinite,
2523
string: isString,
@@ -61,7 +59,8 @@ module.exports = function sanitizeConfig(config, schema, rootDir) {
6159
}, null);
6260

6361
throw new StyleguidistError(
64-
`Unknown config option ${chalk.bold(key)} with value "${format(value)}" was found.` +
62+
`Unknown config option ${chalk.bold(key)} was found, the value is:\n` +
63+
stringify(value) +
6564
(suggestion ? `\n\nDid you mean ${chalk.bold(suggestion)}?` : '')
6665
);
6766
}
@@ -107,6 +106,10 @@ module.exports = function sanitizeConfig(config, schema, rootDir) {
107106
});
108107
if (!hasRightType) {
109108
const exampleValue = props.example || props.default;
109+
const example = {};
110+
if (exampleValue) {
111+
example[key] = exampleValue;
112+
}
110113
throw new StyleguidistError(
111114
`${chalk.bold(key)} config option should be ${typesList(types)}, received ${typeDetect(
112115
value
@@ -115,9 +118,7 @@ module.exports = function sanitizeConfig(config, schema, rootDir) {
115118
? `
116119
Example:
117120
118-
{
119-
${key}: ${isFunction(exampleValue) ? exampleValue.toString() : format(exampleValue)}
120-
}`
121+
${stringify(example)}`
121122
: '')
122123
);
123124
}

0 commit comments

Comments
 (0)