From 67500d2ba320c8c2a3c9592fa35532f41d9b83ad Mon Sep 17 00:00:00 2001 From: macbre Date: Fri, 14 Jul 2023 13:07:46 +0100 Subject: [PATCH 1/2] npm i --save-dev prettier --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 19e8d01..b0f83db 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "eslint-config-prettier": "^8.5.0", "eslint-config-wikimedia": "^0.25.0", "jest": "^29.0.0", + "prettier": "^3.0.0", "typescript": "^5.0.2", "yaml-eslint-parser": "^1.0.1" }, From 27a85fc5ea30b0fb3b5f7066ec1a633c9f5104f5 Mon Sep 17 00:00:00 2001 From: macbre Date: Fri, 14 Jul 2023 13:08:17 +0100 Subject: [PATCH 2/2] npm run prettier --- README.md | 6 +- examples/editSandbox.js | 4 +- examples/getUserContribs.js | 4 +- examples/lastEditsStats.js | 2 +- examples/meaninglessNamedImages.js | 16 ++-- examples/move.js | 2 +- examples/pagesInCategory.js | 2 +- examples/scribuntoConsole.js | 10 +-- examples/scribuntoRemoteDebug.js | 10 +-- examples/siteInfo.js | 8 +- examples/specialLog2csv.js | 2 +- examples/upload.js | 2 +- examples/whois.js | 2 +- examples/wikiaArticleJson.js | 2 +- examples/wikidata.js | 8 +- lib/api.js | 16 ++-- lib/bot.d.ts | 36 ++++----- lib/bot.js | 117 +++++++++++++++-------------- lib/utils.js | 2 +- lib/wikidata.js | 2 +- package-lock.json | 22 ++++++ test/fetchurl-test.js | 2 +- test/mediawiki-api-test.js | 6 +- test/wikidata-test.js | 2 +- 24 files changed, 154 insertions(+), 131 deletions(-) diff --git a/README.md b/README.md index da13246..415521c 100644 --- a/README.md +++ b/README.md @@ -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); - } + }, ); ``` @@ -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 diff --git a/examples/editSandbox.js b/examples/editSandbox.js index 09ced24..191b3ca 100755 --- a/examples/editSandbox.js +++ b/examples/editSandbox.js @@ -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') ); } - } + }, ); diff --git a/examples/getUserContribs.js b/examples/getUserContribs.js index c928e47..6c1bcc6 100644 --- a/examples/getUserContribs.js +++ b/examples/getUserContribs.js @@ -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}).`, ); } - } + }, ); diff --git a/examples/lastEditsStats.js b/examples/lastEditsStats.js index cc57fd8..738866e 100644 --- a/examples/lastEditsStats.js +++ b/examples/lastEditsStats.js @@ -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:'); diff --git a/examples/meaninglessNamedImages.js b/examples/meaninglessNamedImages.js index 5c1382e..c4579b6 100644 --- a/examples/meaninglessNamedImages.js +++ b/examples/meaninglessNamedImages.js @@ -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 `); @@ -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 `); @@ -90,7 +90,7 @@ client.logIn(function () { "[[Użytkownik:OzgaBot|OzgaBot]] wstawia szablon 'Obraz sierota'", function () { console.log(filename + " został oznaczony jako obraz sierota"); - } + }, ); } }); diff --git a/examples/move.js b/examples/move.js index 805bf41..d15c331 100644 --- a/examples/move.js +++ b/examples/move.js @@ -16,6 +16,6 @@ client.logIn(function () { "test summary", function (userData) { console.log(JSON.stringify(userData, null, "\t")); - } + }, ); }); diff --git a/examples/pagesInCategory.js b/examples/pagesInCategory.js index 0e517c5..6bd1040 100644 --- a/examples/pagesInCategory.js +++ b/examples/pagesInCategory.js @@ -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, " "), ); }); }); diff --git a/examples/scribuntoConsole.js b/examples/scribuntoConsole.js index b514463..65fa269 100644 --- a/examples/scribuntoConsole.js +++ b/examples/scribuntoConsole.js @@ -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); } diff --git a/examples/scribuntoRemoteDebug.js b/examples/scribuntoRemoteDebug.js index 63258c5..5bba3a3 100644 --- a/examples/scribuntoRemoteDebug.js +++ b/examples/scribuntoRemoteDebug.js @@ -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); } diff --git a/examples/siteInfo.js b/examples/siteInfo.js index afd5dff..9e5e22c 100644 --- a/examples/siteInfo.js +++ b/examples/siteInfo.js @@ -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}`, ); }); @@ -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.`, ); }); @@ -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.`, ); }); @@ -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`, ); }); diff --git a/examples/specialLog2csv.js b/examples/specialLog2csv.js index 5cc627e..3c6f0cb 100755 --- a/examples/specialLog2csv.js +++ b/examples/specialLog2csv.js @@ -56,5 +56,5 @@ async.whilst( } client.log("Done"); - } + }, ); diff --git a/examples/upload.js b/examples/upload.js index 69cf7a4..5613935 100644 --- a/examples/upload.js +++ b/examples/upload.js @@ -28,7 +28,7 @@ client.logIn((_, res) => { (___, editRes) => { console.log("File description edited"); console.log(editRes); - } + }, ); }); }); diff --git a/examples/whois.js b/examples/whois.js index 7dd3750..f324d54 100644 --- a/examples/whois.js +++ b/examples/whois.js @@ -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' ) ); diff --git a/examples/wikiaArticleJson.js b/examples/wikiaArticleJson.js index 6fbe894..c1a6f4f 100755 --- a/examples/wikiaArticleJson.js +++ b/examples/wikiaArticleJson.js @@ -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) diff --git a/examples/wikidata.js b/examples/wikidata.js index d1e889b..d9708a8 100755 --- a/examples/wikidata.js +++ b/examples/wikidata.js @@ -48,7 +48,7 @@ class WikiData { claims.set("name", titles[idx]); this.bot.log( - `Found entity for ${titles[idx]}: ` + `Found entity for ${titles[idx]}: `, ); Object.keys(raw.entities[key].claims).forEach((propertyId) => { @@ -148,12 +148,12 @@ data.getEntities( fd, Object.keys(itemStats) .map((key) => itemStats[key]) - .join("\t") + "\n" + .join("\t") + "\n", ); }); fs.closeSync(fd); - } + }, ); - } + }, ); diff --git a/lib/api.js b/lib/api.js index b530d4c..dbb079e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -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); @@ -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; @@ -198,7 +198,7 @@ function Api(options) { this.logger.add( new winston.transports.Console({ level: this.debug ? "debug" : "error", - }) + }), ); if (fs.existsSync(logDir)) { @@ -208,7 +208,7 @@ function Api(options) { filename: logFile, json: false, level: this.debug ? "debug" : "info", - }) + }), ); } @@ -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("----"); } @@ -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 { diff --git a/lib/bot.d.ts b/lib/bot.d.ts index f941826..b051257 100644 --- a/lib/bot.d.ts +++ b/lib/bot.d.ts @@ -44,65 +44,65 @@ declare class Bot { title: string, content: string, summary: string, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; doEdit( action: string, title: string, summary: string, params: Object, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; edit( title: string, content: string, summary: string, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; edit( title: string, content: string, summary: string, minor: boolean, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; getArticle(article: string, callback: NodeJSCallback): void; getArticle( article: string, followRedirect: boolean, - callback: NodeJSCallbackDouble + callback: NodeJSCallbackDouble, ): void; getArticleInfo( title: any, options: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; getArticleProperties( title: string, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; getMediaWikiVersion(callback: NodeJSCallback): void; getPagesInCategory( category: string, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; getSiteInfo(props: string[], callback: NodeJSCallback): void; getSiteStats(callback: NodeJSCallback): void; getUserContribs( options: { user: string }, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; logIn(callback: NodeJSCallback): void; logIn( username: string, password: string, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; prepend( title: string, content: string, summary: string, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; search(keyword: string, callback: NodeJSCallback): void; whois(username: string, callback: NodeJSCallback): void; @@ -113,12 +113,12 @@ declare class Bot { title: any, subject: any, content: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; createAccount( username: any, password: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; diff(prev: any, current: any): void; expandTemplates(text: any, title: any, callback: NodeJSCallback): void; @@ -137,7 +137,7 @@ declare class Bot { getImagesFromArticleWithOptions( title: any, options: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; getLog(type: any, start: any, callback: NodeJSCallback): void; getPagesByPrefix(prefix: any, callback: NodeJSCallback): void; @@ -155,27 +155,27 @@ declare class Bot { title: any, protections: any, options: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; purge(titles: any, callback: NodeJSCallback): void; sendEmail( username: any, subject: any, text: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; setConfig(key: any, val: any): void; upload( filename: any, content: any, extraParams: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; uploadByUrl( filename: any, url: any, summary: any, - callback: NodeJSCallback + callback: NodeJSCallback, ): void; uploadVideo(fileName: any, url: any, callback: NodeJSCallback): void; whoami(callback: NodeJSCallback): void; diff --git a/lib/bot.js b/lib/bot.js index 7fe10ba..c27aac0 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -179,7 +179,7 @@ class Bot { } else { callback(null, res); } - } + }, ); } @@ -214,7 +214,8 @@ class Bot { this.error(data.result); this.error(data.reason); callback( - err || new Error(`Logging in failed: ${data.result} - ${data.reason}`) + err || + new Error(`Logging in failed: ${data.result} - ${data.reason}`), ); } }; @@ -248,13 +249,13 @@ class Bot { lgdomain: domain, }, logInCallback, - "POST" + "POST", ); } else { logInCallback(err, data); } }, - "POST" + "POST", ); } @@ -271,7 +272,7 @@ class Bot { aclimit: API_LIMIT, }, (data) => data.allcategories.map((cat) => cat["*"]), - callback + callback, ); } @@ -292,7 +293,7 @@ class Bot { }, function (err, _data) { callback(err, (_data && _data.allusers) || []); - } + }, ); } @@ -306,7 +307,7 @@ class Bot { aplimit: API_LIMIT, }, "allpages", - callback + callback, ); } @@ -322,7 +323,7 @@ class Bot { cmlimit: API_LIMIT, }, "categorymembers", - callback + callback, ); } @@ -338,7 +339,7 @@ class Bot { aplimit: API_LIMIT, }, "allpages", - callback + callback, ); } @@ -354,7 +355,7 @@ class Bot { }, function (err, data) { callback(err, (data && data.allpages) || []); - } + }, ); } @@ -368,7 +369,7 @@ class Bot { titles: template, }, (data) => getFirstItem(getFirstItem(data)).transcludedin, - callback + callback, ); } @@ -419,7 +420,7 @@ class Bot { action: "query", prop: "revisions", rvprop: ["ids", "timestamp", "size", "flags", "comment", "user"].join( - "|" + "|", ), rvdir: "newer", rvlimit: API_LIMIT, @@ -440,7 +441,7 @@ class Bot { const page = getFirstItem(batch.pages); return page.revisions; }, - callback + callback, ); } @@ -470,10 +471,10 @@ class Bot { (page.categories || []).map( (cat) => // { ns: 14, title: 'Kategoria:XX wiek' } - cat.title - ) + cat.title, + ), ); - } + }, ); } @@ -567,7 +568,7 @@ class Bot { const page = getFirstItem(batch.pages); return page; }, - callback + callback, ); } @@ -581,7 +582,7 @@ class Bot { srlimit: 5000, }, "search", - callback + callback, ); } @@ -628,7 +629,7 @@ class Bot { const msg = raw.warnings.info["*"]; this.log(`getToken: ${msg}`); err = new Error( - `Can't get "${action}" token for "${title}" page - ${msg}` + `Can't get "${action}" token for "${title}" page - ${msg}`, ); token = undefined; } @@ -662,7 +663,7 @@ class Bot { summary, }, params, - { token } + { token }, ); this.api.call( @@ -675,7 +676,7 @@ class Bot { callback(_err || data); } }, - "POST" + "POST", ); }); } @@ -729,7 +730,7 @@ class Bot { } this.log( - `Adding a topic to page '${title}' with subject '${subject}'...` + `Adding a topic to page '${title}' with subject '${subject}'...`, ); const params = { @@ -755,14 +756,14 @@ class Bot { this.log( "Workflow '%s' created on '%s'", data["new-topic"].workflow, - title + title, ); callback(null, data); } else { callback(_err); } }, - "POST" + "POST", ); }); } @@ -796,7 +797,7 @@ class Bot { callback(_err); } }, - "POST" + "POST", ); }); } @@ -834,7 +835,7 @@ class Bot { Array.from(protections).forEach((protection) => { if (!protection.type) { callback( - new Error("Invalid protection. An action type must be specified.") + new Error("Invalid protection. An action type must be specified."), ); failed = true; return; @@ -896,7 +897,7 @@ class Bot { callback(_err); } }, - "POST" + "POST", ); }); } @@ -946,7 +947,7 @@ class Bot { callback(err, data); }, - "POST" + "POST", ); } @@ -966,7 +967,7 @@ class Bot { this.log( "Sending an email to '%s' with subject '%s'...", username, - subject + subject, ); this.api.call( @@ -986,7 +987,7 @@ class Bot { callback(_err); } }, - "POST" + "POST", ); }); } @@ -1007,9 +1008,9 @@ class Bot { callback( err, (data && data.usercontribs) || [], - (next && next.ucstart) || false + (next && next.ucstart) || false, ); - } + }, ); } @@ -1036,7 +1037,7 @@ class Bot { } else { callback(err); } - } + }, ); } @@ -1072,7 +1073,7 @@ class Bot { } else { callback(err); } - } + }, ); } @@ -1102,9 +1103,9 @@ class Bot { } callback(_data); }, - "POST" + "POST", ); - } + }, ); } @@ -1139,7 +1140,7 @@ class Bot { callback(_err); } }, - "POST" + "POST", ); }); } @@ -1156,9 +1157,9 @@ class Bot { callback( err, (data && data.allimages) || [], - (next && next.aifrom) || false + (next && next.aifrom) || false, ); - } + }, ); } @@ -1172,7 +1173,7 @@ class Bot { function (err, data) { const page = getFirstItem((data && data.pages) || []); callback(err, (page && page.images) || []); - } + }, ); } @@ -1204,7 +1205,7 @@ class Bot { }, function (err, data) { callback(err, (data && data.imageusage) || []); - } + }, ); } @@ -1232,7 +1233,7 @@ class Bot { } callback(err, imageinfo); - } + }, ); } @@ -1275,7 +1276,7 @@ class Bot { const xml = getFirstItem(raw.parsetree); callback(err, xml); }, - "POST" + "POST", ); } @@ -1297,7 +1298,7 @@ class Bot { images = raw.parse.images; callback(err, xml, images); }, - "POST" + "POST", ); } @@ -1316,9 +1317,9 @@ class Bot { callback( err, (data && data.recentchanges) || [], - (next && next.rcstart) || false + (next && next.rcstart) || false, ); - } + }, ); } @@ -1336,7 +1337,7 @@ class Bot { }, function (err, data) { callback(err, data); - } + }, ); } @@ -1390,13 +1391,13 @@ class Bot { this.log( "%s data was generated %s", queryPage, - data.querypage.cachedtimestamp + data.querypage.cachedtimestamp, ); callback(null, data.querypage.results || []); } else { callback(err, []); } - } + }, ); } @@ -1432,7 +1433,7 @@ class Bot { this.log( "Uploading %s kB as File:%s...", (content.length / 1024).toFixed(2), - filename + filename, ); params.token = token; @@ -1446,7 +1447,7 @@ class Bot { callback(_err); } }, - "UPLOAD" /* fake method to set a proper content type for file uploads */ + "UPLOAD" /* fake method to set a proper content type for file uploads */, ); }); } @@ -1462,7 +1463,7 @@ class Bot { this.upload(filename, content, summary, callback); }, - "binary" /* use binary-safe fetch */ + "binary" /* use binary-safe fetch */, ); } @@ -1489,7 +1490,7 @@ class Bot { "Uploading <%s> (%s provider with video ID %s)", url, provider, - videoId + videoId, ); this.api.call( @@ -1501,7 +1502,7 @@ class Bot { token: token, }, callback, - "POST" /* The addmediapermanent module requires a POST request */ + "POST" /* The addmediapermanent module requires a POST request */, ); }); } @@ -1516,7 +1517,7 @@ class Bot { }, function (err, data) { callback(err, (data && getFirstItem(data.pages).extlinks) || []); - } + }, ); } @@ -1531,7 +1532,7 @@ class Bot { }, function (err, data) { callback(err, (data && data.backlinks) || []); - } + }, ); } @@ -1540,7 +1541,7 @@ class Bot { paramName = paramName.trim().replace("-", "\\-"); const re = new RegExp( - `${paramName}\\s*=([^>]+)` + `${paramName}\\s*=([^>]+)`, ), matches = tmplXml.match(re); @@ -1615,7 +1616,7 @@ Bot.prototype.wikia = { }, function (err, res) { callback(err, res.items); - } + }, ); }, }; diff --git a/lib/utils.js b/lib/utils.js index 7cd2116..4675b53 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -41,7 +41,7 @@ module.exports = { Object.keys(res) .map((key) => `\t${key}: ${typeof res[key]};`) .join("\n") + - "\n}" + "\n}", ); }, }; diff --git a/lib/wikidata.js b/lib/wikidata.js index 7190a81..d5c4f15 100644 --- a/lib/wikidata.js +++ b/lib/wikidata.js @@ -55,7 +55,7 @@ class WikiData { } else { resolve(data); } - } + }, ); }); } diff --git a/package-lock.json b/package-lock.json index bd616c5..40e04cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "eslint-config-prettier": "^8.5.0", "eslint-config-wikimedia": "^0.25.0", "jest": "^29.0.0", + "prettier": "^3.0.0", "typescript": "^5.0.2", "yaml-eslint-parser": "^1.0.1" }, @@ -4647,6 +4648,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz", + "integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "29.6.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.0.tgz", @@ -9410,6 +9426,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz", + "integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==", + "dev": true + }, "pretty-format": { "version": "29.6.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.0.tgz", diff --git a/test/fetchurl-test.js b/test/fetchurl-test.js index ccb0948..a9814ff 100644 --- a/test/fetchurl-test.js +++ b/test/fetchurl-test.js @@ -28,7 +28,7 @@ describe("fetchUrl", () => { done(); }, - "binary" + "binary", ); }); diff --git a/test/mediawiki-api-test.js b/test/mediawiki-api-test.js index 6c41664..ed33b6d 100644 --- a/test/mediawiki-api-test.js +++ b/test/mediawiki-api-test.js @@ -55,7 +55,7 @@ describe("MediaWiki API", () => { expect(article).toContain("''Albert Einstein''"); done(); - } + }, ); }, 5000); @@ -75,7 +75,7 @@ describe("Bot on test.wikipedia.org", () => { if (process.env.CI === "true") { it.skip( "GitHub Actions are blocked by Wikipedia for anon traffic", - it.todo + it.todo, ); return; } @@ -105,7 +105,7 @@ describe("Bot on test.wikipedia.org", () => { lastRevisionId = res.newrevid; done(); - } + }, ); }, 5000); diff --git a/test/wikidata-test.js b/test/wikidata-test.js index 62924f0..a5424c0 100644 --- a/test/wikidata-test.js +++ b/test/wikidata-test.js @@ -97,7 +97,7 @@ describe("WikiData API", () => { it.skip(`rejects for not existing entity`, async () => { // https://jestjs.io/docs/tutorial-async#rejects await expect( - await client.getEntityClaims(NOT_EXISTING_ENTITY) + await client.getEntityClaims(NOT_EXISTING_ENTITY), ).rejects.toMatch(/Error returned by API/); }); });