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:
valadaptive 2023-12-02 09:09:22 -05:00
parent 7c3dd75e6a
commit 12cdb76a20
2 changed files with 2 additions and 5 deletions

View File

@ -70,7 +70,6 @@ module.exports = {
'no-empty': 'off',
'no-unsafe-finally': 'off',
'no-dupe-keys': 'off',
'no-irregular-whitespace': 'off',
'no-regex-spaces': 'off'
'no-irregular-whitespace': 'off'
}
};

View File

@ -12,9 +12,7 @@ const writeFileAtomicSync = require('write-file-atomic').sync;
*/
function safeStr(x) {
x = String(x);
for (let i = 0; i < 16; i++) {
x = x.replace(/ /g, ' ');
}
x = x.replace(/ +/g, ' ');
x = x.trim();
x = x.replace(/^[\s,.]+|[\s,.]+$/g, '');
return x;