Skip to content

Commit

Permalink
Merge pull request #448 from macbre/add/prettier
Browse files Browse the repository at this point in the history
Install prettier
  • Loading branch information
macbre authored Jul 14, 2023
2 parents 8af6b09 + 27a85fc commit 4b2e51c
Show file tree
Hide file tree
Showing 25 changed files with 155 additions and 131 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ client.api.call(
err /* Error instance or null */,
info /* processed query result */,
next /* more results? */,
data /* raw data */
data /* raw data */,
) {
console.log(data && data.query && data.query.results);
}
},
);
```

Expand Down Expand Up @@ -390,7 +390,7 @@ const client = new wikidata();
// Where is Saksun, Faroe Islands located?
const geo = await client.getEntityClaim(
"Q928875" /* Saksun */,
"P625" /* place location */
"P625" /* place location */,
);

// will give you the geolocation of the place
Expand Down
4 changes: 2 additions & 2 deletions examples/editSandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ client.append(
client.log("Sandbox edit failed: " + JSON.stringify(err));
} else {
client.log(
`Edited "${res.title}" as revision #${res.newrevid} on ${res.newtimestamp}.`
`Edited "${res.title}" as revision #${res.newrevid} on ${res.newtimestamp}.`,
);

// console.log( Object.keys(res).map( key => `${key}: ${typeof res[key]};`).join('\n') );
}
}
},
);
4 changes: 2 additions & 2 deletions examples/getUserContribs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ client.getUserContribs(
} else {
const contrib = data[0];
console.log(
`${contrib.user} made an edit to ${contrib.title} on ${contrib.timestamp} (${contrib.comment}).`
`${contrib.user} made an edit to ${contrib.title} on ${contrib.timestamp} (${contrib.comment}).`,
);
}
}
},
);
2 changes: 1 addition & 1 deletion examples/lastEditsStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ client.getRecentChanges(false, function (err, data) {

// emit results
console.log(
`Stats for the last ${count} recent changes (from ${from} back to ${to})...`
`Stats for the last ${count} recent changes (from ${from} back to ${to})...`,
);

// console.log('Pages statistcs:');
Expand Down
16 changes: 8 additions & 8 deletions examples/meaninglessNamedImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ client.logIn(function () {
`[[Użytkownik:OzgaBot|OzgaBot]] dodaje plik do kategorii ${title}`,
function () {
console.log(
title1 + extension + " another one bites the dust xD"
title1 + extension + " another one bites the dust xD",
);
}
},
);
}
},
);
}
},
);
} else {
console.log(`plik ${title1}${extension} już istnieje `);
Expand All @@ -60,12 +60,12 @@ client.logIn(function () {
`[[Użytkownik:OzgaBot|OzgaBot]] dodaje plik do kategorii ${title}`,
function () {
console.log(
title + extension + " another one bites the dust xD"
title + extension + " another one bites the dust xD",
);
}
},
);
});
}
},
);
} else {
console.log(`plik ${title}${extension} już istnieje `);
Expand All @@ -90,7 +90,7 @@ client.logIn(function () {
"[[Użytkownik:OzgaBot|OzgaBot]] wstawia szablon 'Obraz sierota'",
function () {
console.log(filename + " został oznaczony jako obraz sierota");
}
},
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion examples/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ client.logIn(function () {
"test summary",
function (userData) {
console.log(JSON.stringify(userData, null, "\t"));
}
},
);
});
2 changes: 1 addition & 1 deletion examples/pagesInCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ client.getPagesInCategory("Sports_cars", (_, pages) => {
console.log(
"%s: %s",
page.title,
content.slice(0, 75).replace(/\n/g, " ")
content.slice(0, 75).replace(/\n/g, " "),
);
});
});
Expand Down
10 changes: 5 additions & 5 deletions examples/scribuntoConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ function session(err, content) {
params.content = content;
console.log(
c.green(
'* The module exports are available as the variable "p", including unsaved modifications.'
)
'* The module exports are available as the variable "p", including unsaved modifications.',
),
);
console.log(
c.green(
'* Precede a line with "=" to evaluate it as an expression, or use print().'
)
'* Precede a line with "=" to evaluate it as an expression, or use print().',
),
);
console.log(
c.green("* Use mw.log() in module code to send messages to this console.")
c.green("* Use mw.log() in module code to send messages to this console."),
);
rl.on("line", cli);
}
Expand Down
10 changes: 5 additions & 5 deletions examples/scribuntoRemoteDebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ function session(err, data) {
params.content = data;
console.log(
c.green(
'* The module exports are available as the variable "p", including unsaved modifications.'
)
'* The module exports are available as the variable "p", including unsaved modifications.',
),
);
console.log(
c.green(
'* Precede a line with "=" to evaluate it as an expression, or use print().'
)
'* Precede a line with "=" to evaluate it as an expression, or use print().',
),
);
console.log(
c.green("* Use mw.log() in module code to send messages to this console.")
c.green("* Use mw.log() in module code to send messages to this console."),
);
rl.on("line", cli);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/siteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ client.getSiteInfo(["general", "namespaces", "dbrepllag"], function (_, info) {

// e.g. This site uses PHP v7.3.33 and mysql v8.0.25-15
console.log(
`This site uses PHP v${info.general.phpversion} and ${info.general.dbtype} v${info.general.dbversion}`
`This site uses PHP v${info.general.phpversion} and ${info.general.dbtype} v${info.general.dbversion}`,
);
});

Expand All @@ -32,7 +32,7 @@ client.getSiteStats(function (_, stats) {

// e.g. This wiki has 179 articles with 30886001 users that made 1917 edits.
console.log(
`This wiki has ${stats.articles} articles with ${stats.users} users that made ${stats.edits} edits.`
`This wiki has ${stats.articles} articles with ${stats.users} users that made ${stats.edits} edits.`,
);
});

Expand All @@ -42,7 +42,7 @@ client.wikia.getWikiVariables(function (_, vars) {

// e.g. This wiki has ID 443275 (DB name pl8bit) and is a part of lifestyle vertical.
console.log(
`This wiki has ID ${vars.id} (DB name ${vars.dbName}) and is a part of ${vars.vertical} vertical.`
`This wiki has ID ${vars.id} (DB name ${vars.dbName}) and is a part of ${vars.vertical} vertical.`,
);
});

Expand All @@ -54,6 +54,6 @@ client.wikia.getUsers([2, 1, 16], function (_, users) {
client.wikia.getUser(119245, function (_, userInfo) {
// e.g. Hi, I'm Macbre and I've made 15541 edits
console.log(
`Hi, I'm ${userInfo.name} and I've made ${userInfo.numberofedits} edits`
`Hi, I'm ${userInfo.name} and I've made ${userInfo.numberofedits} edits`,
);
});
2 changes: 1 addition & 1 deletion examples/specialLog2csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ async.whilst(
}

client.log("Done");
}
},
);
2 changes: 1 addition & 1 deletion examples/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ client.logIn((_, res) => {
(___, editRes) => {
console.log("File description edited");
console.log(editRes);
}
},
);
});
});
2 changes: 1 addition & 1 deletion examples/whois.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ client.whois("Jimbo Wales", function (err, userData) {
}

console.log(
`${userData.name} made ${userData.editcount} edits since registering on ${userData.registration}.`
`${userData.name} made ${userData.editcount} edits since registering on ${userData.registration}.`,
);

// console.log( JSON.stringify( userData, null, '\t' ) );
Expand Down
2 changes: 1 addition & 1 deletion examples/wikiaArticleJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ client.wikia.call("/Articles/AsSimpleJson", { id: PAGE_ID }, (err, data) => {
let excerpt = data.sections
// get content entries of type "paragraph"
.map((section) =>
section.content.filter((content) => content.type === "paragraph")
section.content.filter((content) => content.type === "paragraph"),
)
// filter out empty sections
.filter((section) => section.length > 0)
Expand Down
8 changes: 4 additions & 4 deletions examples/wikidata.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class WikiData {
claims.set("name", titles[idx]);

this.bot.log(
`Found entity for ${titles[idx]}: <https://www.wikidata.org/wiki/${key}>`
`Found entity for ${titles[idx]}: <https://www.wikidata.org/wiki/${key}>`,
);

Object.keys(raw.entities[key].claims).forEach((propertyId) => {
Expand Down Expand Up @@ -148,12 +148,12 @@ data.getEntities(
fd,
Object.keys(itemStats)
.map((key) => itemStats[key])
.join("\t") + "\n"
.join("\t") + "\n",
);
});

fs.closeSync(fd);
}
},
);
}
},
);
16 changes: 8 additions & 8 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function doRequest(params, callback, method, done) {
} else {
// send attachment
postBody.push(
`Content-Disposition: form-data; name="${fieldName}"; filename="foo"`
`Content-Disposition: form-data; name="${fieldName}"; filename="foo"`,
);
postBody.push(CRLF);
postBody.push(CRLF);
Expand Down Expand Up @@ -111,15 +111,15 @@ function doRequest(params, callback, method, done) {
this.logger.error(
"Request to API failed: HTTP status code was %d for <%s>",
response.statusCode || "unknown",
options.url
options.url,
);
this.logger.debug("Body: %s", body);
this.logger.error("Stacktrace", new Error().stack);

callback(
new Error(
`Request to API failed: HTTP status code was ${response.statusCode}`
)
`Request to API failed: HTTP status code was ${response.statusCode}`,
),
);
done();
return;
Expand Down Expand Up @@ -198,7 +198,7 @@ function Api(options) {
this.logger.add(
new winston.transports.Console({
level: this.debug ? "debug" : "error",
})
}),
);

if (fs.existsSync(logDir)) {
Expand All @@ -208,7 +208,7 @@ function Api(options) {
filename: logFile,
json: false,
level: this.debug ? "debug" : "info",
})
}),
);
}

Expand All @@ -234,7 +234,7 @@ function Api(options) {
let port = this.port ? `:${this.port}` : "";

this.info(
`Using <${this.protocol}://${this.server}${port}${this.path}/api.php> as API entry point`
`Using <${this.protocol}://${this.server}${port}${this.path}/api.php> as API entry point`,
);
this.info("----");
}
Expand Down Expand Up @@ -288,7 +288,7 @@ Api.prototype = {
this.info(
"<%s>: fetched %s kB",
url,
(body.length / 1024).toFixed(2)
(body.length / 1024).toFixed(2),
);
callback(null, body);
} else {
Expand Down
Loading

0 comments on commit 4b2e51c

Please sign in to comment.