Fix some ESLint rules (indentation) (#1161)

This commit is contained in:
Jaifroid 2023-11-13 21:07:52 +00:00 committed by GitHub
parent e772cffd13
commit 9a7419d2d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 142 additions and 139 deletions

View File

@ -25,7 +25,6 @@
// The global parameters object is defined in init.js
/* global params, webpMachine, $ */
/* eslint-disable indent */
// import styles from '../css/app.css' assert { type: "css" };
// import bootstrap from '../css/bootstrap.min.css' assert { type: "css" };
@ -2400,8 +2399,7 @@ function goToMainArticle () {
'<a href="https://pwa.kiwix.org" target="_blank">https://pwa.kiwix.org</a>.</p>' +
'<p>Alternatively, you can use Kiwix Serve to serve this archive to your browser from localhost. ' +
'Kiwix Serve is included with <a href="https://www.kiwix.org/applications/" target="_blank">Kiwix Desktop</a>.</p>',
translateUI.t('dialog-unsupported-archivetype-title') || 'Unsupported archive type!'
);
translateUI.t('dialog-unsupported-archivetype-title') || 'Unsupported archive type!');
document.getElementById('searchingArticles').style.display = 'none';
document.getElementById('welcomeText').style.display = '';
} else {

View File

@ -2,20 +2,19 @@
* Simple Array.from polyfill (with Set support) from https://stackoverflow.com/a/62682524/9727685
*/
(function () {
function arrayFrom (arr, callbackFn, thisArg) {
// if you need you can uncomment the following line
// if(!arr || typeof arr == 'function')throw new Error('This function requires an array-like object - not null, undefined or a function');
function arrayFrom(arr, callbackFn, thisArg) {
//if you need you can uncomment the following line
//if(!arr || typeof arr == 'function')throw new Error('This function requires an array-like object - not null, undefined or a function');
var arNew = [];
var k = []; // used for convert Set to an Array
var i = 0;
var v;
var arNew = [],
k = [], // used for convert Set to an Array
i = 0,
v;
//if you do not need a Set object support then
//you can comment or delete the following if statement
// if you do not need a Set object support then
// you can comment or delete the following if statement
if (window.Set && arr instanceof Set) {
//we use forEach from Set object
// we use forEach from Set object
arr.forEach(function (v) {
k.push(v)
});
@ -24,12 +23,12 @@
for (; i < (arr.length || arr.size); i++) {
v = typeof arr[i] !== 'undefined' ? arr[i] : arr.get ? arr.get(i) : null;
arNew[i] = callbackFn ?
callbackFn.call(thisArg, v, i, arr) : v;
arNew[i] = callbackFn
? callbackFn.call(thisArg, v, i, arr) : v;
}
return arNew;
}
//You could also use it without the following line, but it is not recommended because native function is faster.
Array.from = Array.from || arrayFrom; //We set it as polyfill
// You could also use it without the following line, but it is not recommended because native function is faster.
Array.from = Array.from || arrayFrom; // We set it as polyfill
}());

View File

@ -1,6 +1,6 @@
'use strict';
/* global define, params */
/* global params */
var regexpCookieKeysToMigrate = new RegExp([
'hideActiveContentWarning', 'showUIAnimations', 'appTheme', 'useCache',

View File

@ -22,6 +22,9 @@
'use strict';
/* eslint-disable indent */
/* eslint-disable one-var */
var regExpFindStringParts = /(?:^|.+?)(?:[\s$£\uFFE5^+=`~<>{}[\]|\u3000-\u303F!-#%-\x2A,-/:;\x3F@\x5B-\x5D_\x7B}\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+|$)/g;
/**
@ -198,18 +201,18 @@ function leftShift (int, bits) {
* @param {Integer} nChr Numerical character code
* @returns {Integer} Converted character code
*/
function b64ToUint6(nChr) {
return nChr > 64 && nChr < 91 ?
nChr - 65 :
nChr > 96 && nChr < 123 ?
nChr - 71 :
nChr > 47 && nChr < 58 ?
nChr + 4 :
nChr === 43 ?
62 :
nChr === 47 ?
63 :
0;
function b64ToUint6 (nChr) {
return nChr > 64 && nChr < 91
? nChr - 65
: nChr > 96 && nChr < 123
? nChr - 71
: nChr > 47 && nChr < 58
? nChr + 4
: nChr === 43
? 62
: nChr === 47
? 63
: 0;
}
/**
@ -219,8 +222,8 @@ function b64ToUint6(nChr) {
* @param {Integer} nBlocksSize Optional block size
* @returns {Uint8Array} A Uint8Array containing the converted data
*/
function base64DecToArr(sBase64, nBlocksSize) {
var sB64Enc = sBase64.replace(/[^A-Za-z0-9\+\/]/g, ""),
function base64DecToArr (sBase64, nBlocksSize) {
var sB64Enc = sBase64.replace(/[^A-Za-z0-9+/]/g, ''),
nInLen = sB64Enc.length,
nOutLen = nBlocksSize ? Math.ceil((nInLen * 3 + 1 >> 2) / nBlocksSize) * nBlocksSize : nInLen * 3 + 1 >> 2,
taBytes = new Uint8Array(nOutLen);
@ -242,7 +245,7 @@ function base64DecToArr(sBase64, nBlocksSize) {
* @param {String} dataURI The data URI to convert
* @returns {Uint8Array} A Uint8Array with the converted buffer
*/
function dataURItoUint8Array(dataURI) {
function dataURItoUint8Array (dataURI) {
var parsedString = dataURI.match(/^data:([^,]*),(.*)/i);
if (parsedString && /base64/i.test(parsedString[1])) {
return base64DecToArr(parsedString[2]);
@ -282,7 +285,7 @@ var PromiseQueue = {
return new Promise(function (resolve, reject) {
// Don't allow more than four dialogues to queue up
if (that._queue.length >= 4) reject(new Error('PromiseQueue: queue length exceeded'));
else that._queue.push({promise: promiseFactory, resolve: resolve, reject: reject});
else that._queue.push({ promise: promiseFactory, resolve: resolve, reject: reject });
if (!that._working) that._dequeue();
});
},

View File

@ -21,6 +21,8 @@
*/
'use strict';
/* global self, params */
import uiUtil from './uiUtil.js';
import XZASM from './xzdec-asm.js';
import XZWASM from './xzdec-wasm.js';
@ -64,6 +66,7 @@ if (XZMachineType === 'WASM') {
params.decompressorAPI.assemblerMachineType = XZMachineType;
xzdec = instance;
}).catch(function (err) {
console.warn('WASM xz decoder failed to load, falling back to ASM', err);
XZMachineType = 'ASM';
loadASM();
});
@ -99,7 +102,7 @@ var busy = false;
* @param {Integer} chunkSize
* @returns {Decompressor}
*/
function Decompressor(reader, chunkSize) {
function Decompressor (reader, chunkSize) {
params.decompressorAPI.decompressorLastUsed = 'XZ';
this._chunkSize = chunkSize || 1024 * 5;
this._reader = reader;
@ -111,7 +114,7 @@ function Decompressor(reader, chunkSize) {
* @param {Integer} offset
* @param {Integer} length
*/
Decompressor.prototype.readSlice = function(offset, length) {
Decompressor.prototype.readSlice = function (offset, length) {
busy = true;
var that = this;
this._inStreamPos = 0;
@ -119,7 +122,7 @@ Decompressor.prototype.readSlice = function(offset, length) {
this._decHandle = xzdec._init_decompression(this._chunkSize);
this._outBuffer = new Int8Array(new ArrayBuffer(length));
this._outBufferPos = 0;
return this._readLoop(offset, length).then(function(data) {
return this._readLoop(offset, length).then(function (data) {
xzdec._release(that._decHandle);
busy = false;
return data;
@ -156,9 +159,9 @@ Decompressor.prototype.readSliceSingleThread = function (offset, length) {
* @param {Integer} length
* @returns {Array}
*/
Decompressor.prototype._readLoop = function(offset, length) {
Decompressor.prototype._readLoop = function (offset, length) {
var that = this;
return this._fillInBufferIfNeeded().then(function() {
return this._fillInBufferIfNeeded().then(function () {
var ret = xzdec._decompress(that._decHandle);
var finished = false;
if (ret === 0) {
@ -172,22 +175,23 @@ Decompressor.prototype._readLoop = function(offset, length) {
}
var outPos = xzdec._get_out_pos(that._decHandle);
if (outPos > 0 && that._outStreamPos + outPos >= offset)
{
if (outPos > 0 && that._outStreamPos + outPos >= offset) {
var outBuffer = xzdec._get_out_buffer(that._decHandle);
var copyStart = offset - that._outStreamPos;
if (copyStart < 0)
if (copyStart < 0) {
copyStart = 0;
for (var i = copyStart; i < outPos && that._outBufferPos < that._outBuffer.length; i++)
}
for (var i = copyStart; i < outPos && that._outBufferPos < that._outBuffer.length; i++) {
that._outBuffer[that._outBufferPos++] = xzdec.HEAP8[outBuffer + i];
}
}
that._outStreamPos += outPos;
if (outPos > 0)
xzdec._out_buffer_cleared(that._decHandle);
if (finished || that._outStreamPos >= offset + length)
if (outPos > 0) { xzdec._out_buffer_cleared(that._decHandle); }
if (finished || that._outStreamPos >= offset + length) {
return that._outBuffer;
else
} else {
return that._readLoop(offset, length);
}
});
};
@ -195,14 +199,13 @@ Decompressor.prototype._readLoop = function(offset, length) {
*
* @returns {Promise}
*/
Decompressor.prototype._fillInBufferIfNeeded = function() {
Decompressor.prototype._fillInBufferIfNeeded = function () {
if (!xzdec._input_empty(this._decHandle)) {
return Promise.resolve(0);
}
var that = this;
return this._reader(this._inStreamPos, this._chunkSize).then(function(data) {
if (data.length > that._chunkSize)
data = data.slice(0, that._chunkSize);
return this._reader(this._inStreamPos, this._chunkSize).then(function (data) {
if (data.length > that._chunkSize) { data = data.slice(0, that._chunkSize); }
// For some reason, xzdec.writeArrayToMemory does not seem to be available, and is equivalent to xzdec.HEAP8.set
xzdec.HEAP8.set(data, xzdec._get_in_buffer(that._decHandle));
that._inStreamPos += data.length;

View File

@ -176,7 +176,7 @@ Decompressor.prototype.readSlice = function (offset, length) {
}
return this._readLoop(offset, length).then(function (data) {
// DEV: We are re-using all the allocated w/asm memory, so we do not need to free any of structures assigned wiht _malloc
// DEV: We are re-using all the allocated w/asm memory, so we do not need to free any of structures assigned with _malloc
// However, should you need to free assigned structures use, e.g., zd._free(zd._inBuffer.src);
// Additionally, freeing zd._decHandle is not needed, and actually increases memory consumption (crashing zstddeclib)
// Should you need to free the decoder stream handle, use command below, but be sure to create a new stream control object