[5.4.0] Update eslint target to 2017 and do initial fixes (#9135)

* eslint manual fixes
- update eslint to 2017
- add self to forbidden globals
- fix a few unfixable bugs caught by eslint
- convert newer features in twitter-archivist

* add eslint plugin to forbid features

* import changes from @saqimtiaz

* add package.json changes
This commit is contained in:
Arlen Beiler
2025-10-01 10:08:00 -04:00
committed by GitHub
parent 5389dc0fa7
commit f8170cd50a
7 changed files with 108 additions and 88 deletions

View File

@@ -25,7 +25,7 @@ exports.startup = function() {
var gaMeasurementID = $tw.wiki.getTiddlerText("$:/GoogleAnalyticsMeasurementID","").replace(/\n/g,"");
var url ="https://www.googletagmanager.com/gtag/js?id=" + gaMeasurementID;
window.dataLayer = window.dataLayer || [];
window.gtag = function() { window.dataLayer?.push(arguments); };
window.gtag = function() { if(window.dataLayer) window.dataLayer.push(arguments); };
window.gtag("js",new Date());
window.gtag("config",gaMeasurementID);
const scriptElement = window.document.createElement("script");

View File

@@ -7,6 +7,8 @@ Utility class for manipulating Twitter archives
\*/
/* eslint-disable no-await-in-loop */
/* eslint-disable require-await */
"use strict";
function TwitterArchivist(options) {
@@ -228,13 +230,22 @@ TwitterArchivistSourceBrowser.prototype.init = async function() {
TwitterArchivistSourceBrowser.prototype.processFiles = async function(dirPath,encoding,callback) {
const dirHandle = await this.walkDirectory(dirPath.split("/"));
for await (const [filename, fileHandle] of dirHandle.entries()) {
const asyncIterator = dirHandle.entries();
await AsyncIteratorForEach(asyncIterator, async ([filename, fileHandle]) => {
const contents = await fileHandle.getFile();
callback({
filename: filename,
contents: arrayBufferToBase64(await contents.arrayBuffer())
contents: encoding === "base64" ? arrayBufferToBase64(await contents.arrayBuffer()) : await contents.text()
});
}
});
// for await (const [filename, fileHandle] of dirHandle.entries()) {
// const contents = await fileHandle.getFile();
// callback({
// filename: filename,
// contents: arrayBufferToBase64(await contents.arrayBuffer())
// });
// }
};
TwitterArchivistSourceBrowser.prototype.loadTwitterJsData = async function(filePath) {
@@ -309,6 +320,26 @@ function arrayBufferToBase64(arrayBuffer) {
return base64;
}
async function AsyncIteratorForEach(iter, callback) {
// Start the iteration
try {
while(true) {
// Await the next result object
const { value, done } = await iter.next();
if(done) break;
await callback(value);
}
} finally {
// If the iterator supports cleanup, call it
if(typeof iter.return === "function") {
await iter.return();
}
}
}
exports.TwitterArchivist = TwitterArchivist;
exports.TwitterArchivistSourceNodeJs = TwitterArchivistSourceNodeJs;
exports.TwitterArchivistSourceBrowser = TwitterArchivistSourceBrowser;

View File

@@ -144,7 +144,7 @@ XLSXImporter.prototype.processField = function(fieldImportSpecTitle) {
value = cell.v.toString();
break;
case "string":
// Intentional fall-through
// falls through
default:
value = cell.w;
break;