Skip to content

Commit 421c333

Browse files
committed
style(prettier): Upgrade to prettier 1.0.0
Fixes #709
1 parent 6bc33fd commit 421c333

35 files changed

+313
-338
lines changed

Diff for: lib/commands/build.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ module.exports.handler = function build(argv /*: Object*/) {
4949
if (!argv.input.length) {
5050
try {
5151
argv.input = [
52-
JSON.parse(
53-
fs.readFileSync(path.resolve('package.json'), 'utf8')
54-
).main || 'index.js'
52+
JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'))
53+
.main || 'index.js'
5554
];
5655
} catch (e) {
5756
throw new Error(
@@ -70,7 +69,8 @@ module.exports.handler = function build(argv /*: Object*/) {
7069
return documentation
7170
.build(argv.input, argv)
7271
.then(comments =>
73-
documentation.formats[argv.format](comments, argv).then(onFormatted))
72+
documentation.formats[argv.format](comments, argv).then(onFormatted)
73+
)
7474
.catch(err => {
7575
/* eslint no-console: 0 */
7676
if (err instanceof Error) {
@@ -110,8 +110,9 @@ module.exports.handler = function build(argv /*: Object*/) {
110110
.expandInputs(argv.input, argv)
111111
.then(files =>
112112
watcher.add(
113-
files.map(data => typeof data === 'string' ? data : data.file)
114-
));
113+
files.map(data => (typeof data === 'string' ? data : data.file))
114+
)
115+
);
115116
}
116117

117118
return generator();

Diff for: lib/commands/lint.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ module.exports.handler = function(argv /*: Object*/) {
2424
if (!argv.input.length) {
2525
try {
2626
argv.input = [
27-
JSON.parse(
28-
fs.readFileSync(path.resolve('package.json'), 'utf8')
29-
).main || 'index.js'
27+
JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'))
28+
.main || 'index.js'
3029
];
3130
} catch (e) {
3231
throw new Error(

Diff for: lib/commands/readme.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ module.exports.handler = function readme(argv /*: Object*/) {
5757
if (!argv.input.length) {
5858
try {
5959
argv.input = [
60-
JSON.parse(
61-
fs.readFileSync(path.resolve('package.json'), 'utf8')
62-
).main || 'index.js'
60+
JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'))
61+
.main || 'index.js'
6362
];
6463
} catch (e) {
6564
throw new Error(
@@ -85,7 +84,8 @@ module.exports.handler = function readme(argv /*: Object*/) {
8584
section: argv.section,
8685
toInject: JSON.parse(docsAst)
8786
})
88-
.process(readmeContent))
87+
.process(readmeContent)
88+
)
8989
.then(file => {
9090
var diffOutput = disparity.unified(readmeContent, file.contents, {
9191
paths: [argv.readmeFile, argv.readmeFile]

Diff for: lib/commands/serve.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ module.exports.handler = function serve(argv /*: Object*/) {
4444
if (!argv.input.length) {
4545
try {
4646
argv.input = [
47-
JSON.parse(
48-
fs.readFileSync(path.resolve('package.json'), 'utf8')
49-
).main || 'index.js'
47+
JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'))
48+
.main || 'index.js'
5049
];
5150
} catch (e) {
5251
throw new Error(
@@ -72,7 +71,7 @@ module.exports.handler = function serve(argv /*: Object*/) {
7271
.expandInputs(argv.input, argv)
7372
.then(files => {
7473
watcher.add(
75-
files.map(data => typeof data === 'string' ? data : data.file)
74+
files.map(data => (typeof data === 'string' ? data : data.file))
7675
);
7776
})
7877
.catch(err => {

Diff for: lib/filter_access.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ function filterAccess(
1919
levels = levels || ['public', 'undefined', 'protected'];
2020

2121
function filter(comment) {
22-
return comment.kind === 'note' ||
23-
(!comment.ignore && levels.indexOf(String(comment.access)) !== -1);
22+
return (
23+
comment.kind === 'note' ||
24+
(!comment.ignore && levels.indexOf(String(comment.access)) !== -1)
25+
);
2426
}
2527

2628
function recurse(comment) {

Diff for: lib/flow_doctrine.js

-3
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,13 @@ function flowDoctrine(type /*: Object */) /*: DoctrineType*/ {
7272
type: 'UnionType',
7373
elements: type.types.map(flowDoctrine)
7474
};
75-
7675
// [number]
7776
// [string, boolean, number]
7877
case 'TupleTypeAnnotation':
7978
return {
8079
type: 'ArrayType',
8180
elements: type.types.map(flowDoctrine)
8281
};
83-
8482
// number[]
8583
case 'ArrayTypeAnnotation':
8684
return {
@@ -91,7 +89,6 @@ function flowDoctrine(type /*: Object */) /*: DoctrineType*/ {
9189
},
9290
applications: [flowDoctrine(type.elementType)]
9391
};
94-
9592
// (y: number) => bool
9693
case 'FunctionTypeAnnotation':
9794
return {

Diff for: lib/git/url_prefix.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ function parsePackedRefs(packedRefs, branchName) {
2020
return packedRefs
2121
.split(/\n/)
2222
.filter(line => line[0] !== '#' && line[0] !== '^')
23-
.reduce(
24-
(memo, line) => {
25-
memo[line.split(' ')[1]] = line.split(' ')[0];
26-
return memo;
27-
},
28-
{}
29-
)[branchName];
23+
.reduce((memo, line) => {
24+
memo[line.split(' ')[1]] = line.split(' ')[0];
25+
return memo;
26+
}, {})[branchName];
3027
}
3128

3229
/**
@@ -62,10 +59,12 @@ function getGithubURLPrefix(root /*: string*/) {
6259
sha = head;
6360
}
6461
if (sha) {
65-
return gitUrlParse(getRemoteOrigin.sync(root)).toString('https') +
62+
return (
63+
gitUrlParse(getRemoteOrigin.sync(root)).toString('https') +
6664
'/blob/' +
6765
sha.trim() +
68-
'/';
66+
'/'
67+
);
6968
}
7069
} catch (e) {
7170
return null;

Diff for: lib/hierarchy.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -175,26 +175,23 @@ module.exports = function(comments /*: Array<Comment>*/) {
175175
global: ''
176176
};
177177

178-
comment.namespace = comment.path.reduce(
179-
(memo, part) => {
180-
if (part.kind === 'event') {
181-
return memo + '.event:' + part.name;
182-
}
183-
let scopeChar = '';
184-
if (part.scope) {
185-
scopeChar = scopeChars[part.scope];
186-
}
187-
return memo + scopeChar + part.name;
188-
},
189-
''
190-
);
178+
comment.namespace = comment.path.reduce((memo, part) => {
179+
if (part.kind === 'event') {
180+
return memo + '.event:' + part.name;
181+
}
182+
let scopeChar = '';
183+
if (part.scope) {
184+
scopeChar = scopeChars[part.scope];
185+
}
186+
return memo + scopeChar + part.name;
187+
}, '');
191188

192189
if (hasUndefinedParent) {
193190
var memberOfTag = comment.tags.filter(
194191
tag => tag.title === 'memberof'
195192
)[0];
196-
var memberOfTagLineNumber = (memberOfTag && memberOfTag.lineNumber) ||
197-
0;
193+
var memberOfTagLineNumber =
194+
(memberOfTag && memberOfTag.lineNumber) || 0;
198195

199196
comment.errors.push({
200197
message: `@memberof reference to ${comment.memberof} not found`,

Diff for: lib/infer/membership.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ var n = require('babel-types'),
77
parse = require('../../lib/parse');
88

99
function inferModuleName(comment) {
10-
return (comment.kind === 'module' && comment.name) ||
11-
pathParse(comment.context.file).name;
10+
return (
11+
(comment.kind === 'module' && comment.name) ||
12+
pathParse(comment.context.file).name
13+
);
1214
}
1315

1416
/**
@@ -383,7 +385,8 @@ module.exports = function() {
383385
if (objectParent) {
384386
// The @lends comment is sometimes attached to the first property rather than
385387
// the object expression itself.
386-
var lendsIdentifiers = findLendsIdentifiers(objectParent) ||
388+
var lendsIdentifiers =
389+
findLendsIdentifiers(objectParent) ||
387390
findLendsIdentifiers(objectParent.get('properties')[0]);
388391

389392
if (lendsIdentifiers) {

Diff for: lib/infer/params.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,9 @@ function inferParams(comment /*: Comment */) {
223223
var i = 0;
224224

225225
path.node.params
226-
.reduce(
227-
function(params, param, i) {
228-
return params.concat(paramToDoc(param, comment, i, ''));
229-
},
230-
[]
231-
)
226+
.reduce(function(params, param, i) {
227+
return params.concat(paramToDoc(param, comment, i, ''));
228+
}, [])
232229
.forEach(function(doc) {
233230
if (!existingParams.hasOwnProperty(doc.name)) {
234231
// This type is not explicitly documented

Diff for: lib/input/dependency.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ function dependencyStream(
6666
inputs
6767
.filter(
6868
input =>
69-
// At this point, we may have allowed a JSON file to be caught by
70-
// module-deps, or anything else allowed by requireExtension.
71-
// otherwise module-deps would complain about
72-
// it not being found. But Babel can't parse JSON, so we filter non-JavaScript
73-
// files away.
69+
// At this point, we may have allowed a JSON file to be caught by
70+
// module-deps, or anything else allowed by requireExtension.
71+
// otherwise module-deps would complain about
72+
// it not being found. But Babel can't parse JSON, so we filter non-JavaScript
73+
// files away.
7474
config.parseExtension.indexOf(
7575
path.extname(input.file).replace(/^\./, '')
7676
) > -1

Diff for: lib/is_jsdoc_comment.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ module.exports = function isJSDocComment(
2020
}*/
2121
) {
2222
var asterisks = comment.value.match(/^(\*+)/);
23-
return (comment.type === 'CommentBlock' || // estree
24-
comment.type === 'Block') && // get-comments / traditional
23+
return (
24+
(comment.type === 'CommentBlock' || // estree
25+
comment.type === 'Block') && // get-comments / traditional
2526
asterisks &&
26-
asterisks[1].length === 1;
27+
asterisks[1].length === 1
28+
);
2729
};

Diff for: lib/lint.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ function formatLint(comments /*: Array<Comment>*/) /*: string */ {
7575
walk(comments, function(comment) {
7676
comment.errors.forEach(function(error) {
7777
var p = comment.context.file;
78-
vFiles[p] = vFiles[p] ||
78+
vFiles[p] =
79+
vFiles[p] ||
7980
new VFile({
8081
path: p
8182
});

Diff for: lib/merge_config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ function mergePackage(config /*: Object */) /*: Promise<Object> */ {
5050
(val, key) => `project-${key}`
5151
),
5252
config
53-
))
53+
)
54+
)
5455
// Allow this to fail: this inference is not required.
5556
.catch(() => config)
5657
);

Diff for: lib/module_filters.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ module.exports = {
5959

6060
return function(id /*: string*/, file /*: string*/, pkg /*: Object*/) {
6161
var internal = internalModuleRegexp.test(id);
62-
return internal ||
63-
(externalFilters && externalFilters.some(f => f(file, pkg)));
62+
return (
63+
internal || (externalFilters && externalFilters.some(f => f(file, pkg)))
64+
);
6465
};
6566
}
6667
};

Diff for: lib/output/highlighter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ var hljs = require('highlight.js');
1313
function visitor(node) {
1414
if (node.lang) {
1515
node.type = 'html';
16-
node.value = "<pre class='hljs'>" +
16+
node.value =
17+
"<pre class='hljs'>" +
1718
hljs.highlightAuto(node.value, [node.lang]).value +
1819
'</pre>';
1920
}

0 commit comments

Comments
 (0)