mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-12 18:10:13 +01:00
Merge pull request #1429 from valadaptive/eslint-fixes-1
ESLint fixes, part 1
This commit is contained in:
commit
6be07e5ea5
12
.eslintrc.js
12
.eslintrc.js
@ -59,19 +59,9 @@ module.exports = {
|
|||||||
'no-extra-semi': 'off',
|
'no-extra-semi': 'off',
|
||||||
'no-undef': 'off',
|
'no-undef': 'off',
|
||||||
'no-prototype-builtins': 'off',
|
'no-prototype-builtins': 'off',
|
||||||
'no-unused-labels': 'off',
|
|
||||||
'no-extra-boolean-cast': 'off',
|
'no-extra-boolean-cast': 'off',
|
||||||
'require-yield': 'off',
|
'require-yield': 'off',
|
||||||
'no-case-declarations': 'off',
|
'no-case-declarations': 'off',
|
||||||
'use-isnan': 'off',
|
'no-constant-condition': ['error', {checkLoops: false}]
|
||||||
'no-self-assign': 'off',
|
|
||||||
'no-unsafe-negation': 'off',
|
|
||||||
'no-constant-condition': 'off',
|
|
||||||
'no-empty': 'off',
|
|
||||||
'no-unsafe-finally': 'off',
|
|
||||||
'no-dupe-keys': 'off',
|
|
||||||
'no-irregular-whitespace': 'off',
|
|
||||||
'no-regex-spaces': 'off',
|
|
||||||
'no-fallthrough': 'off'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
esversion: 6
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Generate,
|
Generate,
|
||||||
characters,
|
characters,
|
||||||
|
@ -178,7 +178,7 @@ async function onRegexEditorOpenClick(existingId) {
|
|||||||
.filter(":checked")
|
.filter(":checked")
|
||||||
.map(function () { return parseInt($(this).val()) })
|
.map(function () { return parseInt($(this).val()) })
|
||||||
.get()
|
.get()
|
||||||
.filter((e) => e !== NaN) || [],
|
.filter((e) => !isNaN(e)) || [],
|
||||||
disabled:
|
disabled:
|
||||||
editorHtml
|
editorHtml
|
||||||
.find(`input[name="disabled"]`)
|
.find(`input[name="disabled"]`)
|
||||||
|
@ -115,7 +115,6 @@ class ElevenLabsTtsProvider {
|
|||||||
await this.fetchTtsVoiceObjects().catch(error => {
|
await this.fetchTtsVoiceObjects().catch(error => {
|
||||||
throw `TTS API key validation failed`
|
throw `TTS API key validation failed`
|
||||||
})
|
})
|
||||||
this.settings.apiKey = this.settings.apiKey
|
|
||||||
console.debug(`Saved new API_KEY: ${this.settings.apiKey}`)
|
console.debug(`Saved new API_KEY: ${this.settings.apiKey}`)
|
||||||
$('#tts_status').text('')
|
$('#tts_status').text('')
|
||||||
this.onSettingsChange()
|
this.onSettingsChange()
|
||||||
|
@ -421,12 +421,12 @@ function completeCurrentAudioJob() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts an HTTP response containing audio/mpeg data, and puts the data as a Blob() on the queue for playback
|
* Accepts an HTTP response containing audio/mpeg data, and puts the data as a Blob() on the queue for playback
|
||||||
* @param {*} response
|
* @param {Response} response
|
||||||
*/
|
*/
|
||||||
async function addAudioJob(response) {
|
async function addAudioJob(response) {
|
||||||
const audioData = await response.blob()
|
const audioData = await response.blob()
|
||||||
if (!audioData.type in ['audio/mpeg', 'audio/wav', 'audio/x-wav', 'audio/wave', 'audio/webm']) {
|
if (!audioData.type.startsWith('audio/')) {
|
||||||
throw `TTS received HTTP response with invalid data format. Expecting audio/mpeg, got ${audioData.type}`
|
throw `TTS received HTTP response with invalid data format. Expecting audio/*, got ${audioData.type}`
|
||||||
}
|
}
|
||||||
audioJobQueue.push(audioData)
|
audioJobQueue.push(audioData)
|
||||||
console.debug('Pushed audio job to queue.')
|
console.debug('Pushed audio job to queue.')
|
||||||
|
@ -1604,10 +1604,8 @@ export async function getGroupPastChats(groupId) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
return chats;
|
return chats;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export async function openGroupChat(groupId, chatId) {
|
export async function openGroupChat(groupId, chatId) {
|
||||||
const group = groups.find(x => x.id === groupId);
|
const group = groups.find(x => x.id === groupId);
|
||||||
|
@ -66,7 +66,9 @@ export function formatKoboldUrl(value) {
|
|||||||
url.pathname = '/api';
|
url.pathname = '/api';
|
||||||
}
|
}
|
||||||
return url.toString();
|
return url.toString();
|
||||||
} catch { } // Just using URL as a validation check
|
} catch {
|
||||||
|
// Just using URL as a validation check
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1696,10 +1696,8 @@ async function calculateLogitBias() {
|
|||||||
result = {};
|
result = {};
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class TokenHandler {
|
class TokenHandler {
|
||||||
constructor(countTokenFn) {
|
constructor(countTokenFn) {
|
||||||
|
@ -1281,7 +1281,7 @@ export async function promptQuietForLoudResponse(who, text) {
|
|||||||
} else if (who === 'char') {
|
} else if (who === 'char') {
|
||||||
text = characters[character_id].name + ": " + text;
|
text = characters[character_id].name + ": " + text;
|
||||||
} else if (who === 'raw') {
|
} else if (who === 'raw') {
|
||||||
text = text;
|
// We don't need to modify the text
|
||||||
}
|
}
|
||||||
|
|
||||||
//text = `${text}${power_user.instruct.enabled ? '' : '\n'}${(power_user.always_force_name2 && who != 'raw') ? characters[character_id].name + ":" : ""}`
|
//text = `${text}${power_user.instruct.enabled ? '' : '\n'}${(power_user.always_force_name2 && who != 'raw') ? characters[character_id].name + ":" : ""}`
|
||||||
|
@ -288,7 +288,6 @@ async function statMesProcess(line, type, characters, this_chid, oldMesssage) {
|
|||||||
user_word_count: 0,
|
user_word_count: 0,
|
||||||
non_user_msg_count: 0,
|
non_user_msg_count: 0,
|
||||||
user_msg_count: 0,
|
user_msg_count: 0,
|
||||||
non_user_msg_count: 0,
|
|
||||||
total_swipe_count: 0,
|
total_swipe_count: 0,
|
||||||
date_first_chat: Date.now(),
|
date_first_chat: Date.now(),
|
||||||
date_last_chat: Date.now(),
|
date_last_chat: Date.now(),
|
||||||
|
@ -174,7 +174,9 @@ function formatTextGenURL(value) {
|
|||||||
url.pathname = '/api';
|
url.pathname = '/api';
|
||||||
}
|
}
|
||||||
return url.toString();
|
return url.toString();
|
||||||
} catch { } // Just using URL as a validation check
|
} catch {
|
||||||
|
// Just using URL as a validation check
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1908,6 +1908,7 @@ async function checkWorldInfo(chat, maxContext) {
|
|||||||
entries: [entry.content]
|
entries: [entry.content]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
10
server.js
10
server.js
@ -118,7 +118,9 @@ if (fs.existsSync(whitelistPath)) {
|
|||||||
try {
|
try {
|
||||||
let whitelistTxt = fs.readFileSync(whitelistPath, 'utf-8');
|
let whitelistTxt = fs.readFileSync(whitelistPath, 'utf-8');
|
||||||
whitelist = whitelistTxt.split("\n").filter(ip => ip).map(ip => ip.trim());
|
whitelist = whitelistTxt.split("\n").filter(ip => ip).map(ip => ip.trim());
|
||||||
} catch (e) { }
|
} catch (e) {
|
||||||
|
// Ignore errors that may occur when reading the whitelist (e.g. permissions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const whitelistMode = getConfigValue('whitelistMode', true);
|
const whitelistMode = getConfigValue('whitelistMode', true);
|
||||||
@ -781,7 +783,7 @@ app.post("/getchat", jsonParser, function (request, response) {
|
|||||||
const lines = data.split('\n');
|
const lines = data.split('\n');
|
||||||
|
|
||||||
// Iterate through the array of strings and parse each line as JSON
|
// Iterate through the array of strings and parse each line as JSON
|
||||||
const jsonData = lines.map((l) => { try { return JSON.parse(l); } catch (_) { } }).filter(x => x);
|
const jsonData = lines.map((l) => { try { return JSON.parse(l); } catch (_) { return; } }).filter(x => x);
|
||||||
return response.send(jsonData);
|
return response.send(jsonData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -1285,10 +1287,10 @@ async function charaWrite(img_url, data, target_img, response = undefined, mes =
|
|||||||
for (let tEXtChunk of tEXtChunks) {
|
for (let tEXtChunk of tEXtChunks) {
|
||||||
chunks.splice(chunks.indexOf(tEXtChunk), 1);
|
chunks.splice(chunks.indexOf(tEXtChunk), 1);
|
||||||
}
|
}
|
||||||
// Add new chunks before the IEND chunk
|
// Add new chunks before the IEND chunk
|
||||||
const base64EncodedData = Buffer.from(data, 'utf8').toString('base64');
|
const base64EncodedData = Buffer.from(data, 'utf8').toString('base64');
|
||||||
chunks.splice(-1, 0, PNGtext.encode('chara', base64EncodedData));
|
chunks.splice(-1, 0, PNGtext.encode('chara', base64EncodedData));
|
||||||
//chunks.splice(-1, 0, text.encode('lorem', 'ipsum'));
|
//chunks.splice(-1, 0, text.encode('lorem', 'ipsum'));
|
||||||
|
|
||||||
writeFileAtomicSync(charactersPath + target_img + '.png', Buffer.from(encode(chunks)));
|
writeFileAtomicSync(charactersPath + target_img + '.png', Buffer.from(encode(chunks)));
|
||||||
if (response !== undefined) response.send(mes);
|
if (response !== undefined) response.send(mes);
|
||||||
|
@ -118,9 +118,7 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
catch (err) {
|
catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
return response.send(output);
|
return response.send(output);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,9 +133,7 @@ function registerEndpoints(app, jsonParser, urlencodedParser) {
|
|||||||
catch (err) {
|
catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
return response.send(sprites);
|
return response.send(sprites);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/api/sprites/delete', jsonParser, async (request, response) => {
|
app.post('/api/sprites/delete', jsonParser, async (request, response) => {
|
||||||
|
@ -12,9 +12,7 @@ const writeFileAtomicSync = require('write-file-atomic').sync;
|
|||||||
*/
|
*/
|
||||||
function safeStr(x) {
|
function safeStr(x) {
|
||||||
x = String(x);
|
x = String(x);
|
||||||
for (let i = 0; i < 16; i++) {
|
x = x.replace(/ +/g, ' ');
|
||||||
x = x.replace(/ /g, ' ');
|
|
||||||
}
|
|
||||||
x = x.trim();
|
x = x.trim();
|
||||||
x = x.replace(/^[\s,.]+|[\s,.]+$/g, '');
|
x = x.replace(/^[\s,.]+|[\s,.]+$/g, '');
|
||||||
return x;
|
return x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user