8000 Update code format & match prettier/tslint rules. · lodash/lodash.com@a873515 · GitHub
[go: up one dir, main page]

Skip to content

Commit a873515

Browse files
committed
Update code format & match prettier/tslint rules.
1 parent b462c3c commit a873515

File tree

5 files changed

+368
-358
lines changed

5 files changed

+368
-358
lines changed

plugins/gatsby-source-lodash/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ module.exports = {
2222
...
2323
]
2424
}
25-
```
25+
```
Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
'use strict';
1+
"use strict"
22

3-
const fetch = require("node-fetch"),
4-
_ = require("lodash"),
5-
Entry = require('./lib/entry.js'),
6-
getEntries = Entry.getEntries;
3+
const fetch = require("node-fetch")
4+
const _ = require("lodash")
5+
const Entry = require("./lib/entry.js")
6+
const getEntries = Entry.getEntries
77

88
exports.sourceNodes = (
99
{ actions, createNodeId, createContentDigest },
@@ -15,85 +15,87 @@ exports.sourceNodes = (
1515
delete configOptions.plugins
1616

1717
// TODO: Extend this to include multiple versions
18-
const url = configOptions.versions[0].url,
19-
version = configOptions.versions[0].version;
18+
const url = configOptions.versions[0].url
19+
const version = configOptions.versions[0].version
2020

2121
const processEntry = entry => {
2222
try {
2323
// Exit early if the entry is private or has no name
2424
if (!entry || !entry.getName() || entry.isPrivate()) {
25-
return;
26-
}
25+
return
26+
}
2727
} catch (err) {
2828
// Some of the non-lodash methods were throwing a hard to trace error
29-
// from the lib code. Rather than trace back, it was easier to catch
29+
// from the lib code. Rather than trace back, it was easier to catch
3030
// since they aren't part of lodash.
31-
return;
31+
return
3232
}
3333

3434
// Special handling of aliases to get call names. Without this, there are
3535
// circular JS object references.
3636
const aliases = entry.getAliases().map(alias => {
37-
const member = entry.getMembers(0) || '',
38-
name = alias.getName();
39-
return `${member}.${name}`;
37+
const member = entry.getMembers(0) || ""
38+
const name = alias.getName()
39+
return `${member}.${name}`
4040
})
4141

42-
const params = entry.getParams().map(
43-
([type, name, desc]) => ({ type, name, desc }));
42+
const params = entry
43+
.getParams()
44+
.map(([type, name, desc]) => ({ type, name, desc }))
4445

4546
const entryData = {
4647
aliases,
47-
version,
48-
params,
4948
call: entry.getCall(),
5049
category: entry.getCategory(),
5150
desc: entry.getDesc(),
5251
example: entry.getExample(),
5352
hash: entry.getHash(),
53+
isAlias: entry.isAlias(),
54+
isCtor: entry.isCtor(),
55+
isFunction: entry.isFunction(),
56+
isLicense: entry.isLicense(),
57+
isPlugin: entry.isPlugin(),
58+
isStatic: entry.isStatic(),
5459
lineNumber: entry.getLineNumber(),
5560
members: entry.getMembers(),
5661
name: entry.getName(),
62+
params,
5763
related: entry.getRelated(),
5864
returns: entry.getReturns(),
5965
since: entry.getSince(),
6066
type: entry.getType(),
61-
isAlias: entry.isAlias(),
62-
isCtor: entry.isCtor(),
63-
isFunction: entry.isFunction(),
64-
isLicense: entry.isLicense(),
65-
isPlugin: entry.isPlugin(),
66-
isStatic: entry.isStatic(),
67+
version,
6768
}
6869

69-
const nodeData = _.assign({}, entryData, {
70-
id: createNodeId(`lodash_method_${version}_${entryData.hash}_${entryData.lineNumber}`),
71-
parent: null,
70+
const nodeData = {
71+
...entryData,
7272
children: [],
73+
id: createNodeId(
74+
`lodash_method_${version}_${entryData.hash}_${entryData.lineNumber}`
75+
),
7376
internal: {
74-
type: 'LodashMethod',
7577
content: JSON.stringify(entryData),
7678
contentDigest: createContentDigest(JSON.stringify(entryData)),
77-
}
78-
});
79+
type: "LodashMethod",
80+
},
81+
parent: null,
82+
}
7983

80-
return nodeData;
84+
return nodeData
8185
}
8286

83-
return (
84-
fetch(url)
85-
.then(res => res.text())
86-
.then(body => {
87-
const entries = getEntries(body);
87+
return fetch(url)
88+
.then(res => res.text())
89+
.then(body => {
90+
const entries = getEntries(body)
8891

89-
// For each entry, create node.
90-
_.each(entries, entry => {
91-
entry = new Entry(entry, body);
92-
const nodeData = processEntry(entry);
93-
if (nodeData) {
94-
createNode(nodeData);
95-
}
96-
})
92+
// For each entry, create node.
93+
_.each(entries, entry => {
94+
entry = new Entry(entry, body)
95+
const nodeData = processEntry(entry)
96+
if (nodeData) {
97+
createNode(nodeData)
98+
}
9799
})
98-
)
99-
}
100+
})
101+
}

0 commit comments

Comments
 (0)
0