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-unsafe-finally': 'off',
|
||||
'no-dupe-keys': 'off',
|
||||
'no-irregular-whitespace': 'off',
|
||||
'no-regex-spaces': 'off'
|
||||
'no-irregular-whitespace': 'off'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue