mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-10 00:50:43 +01:00
Enable no-regex-spaces lint
I noticed the old code was replacing two spaces with one space, over and over. Instead, I changed it to remove all consecutive strings of spaces just once, using the "+" quantifier. This should behave the same but is nicer to read and faster.
This commit is contained in:
parent
7c3dd75e6a
commit
12cdb76a20
@ -70,7 +70,6 @@ module.exports = {
|
|||||||
'no-empty': 'off',
|
'no-empty': 'off',
|
||||||
'no-unsafe-finally': 'off',
|
'no-unsafe-finally': 'off',
|
||||||
'no-dupe-keys': 'off',
|
'no-dupe-keys': 'off',
|
||||||
'no-irregular-whitespace': 'off',
|
'no-irregular-whitespace': 'off'
|
||||||
'no-regex-spaces': 'off'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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