enforce eslint radix rule for parseInt

This commit is contained in:
tophf 2021-02-26 13:01:27 +03:00
parent 53c71614fc
commit 41533e863d
5 changed files with 7 additions and 7 deletions

View File

@ -203,7 +203,7 @@ rules:
prefer-const: [1, {destructuring: all, ignoreReadBeforeAssign: true}]
quote-props: [0]
quotes: [1, single, avoid-escape]
radix: [2, as-needed]
radix: [2, always]
require-jsdoc: [0]
require-yield: [2]
semi-spacing: [2, {before: false, after: true}]

View File

@ -678,7 +678,7 @@
el.style.width = newWidth + 'px';
}
const numLines = el.value.split('\n').length;
if (numLines !== parseInt(el.rows)) {
if (numLines !== Number(el.rows)) {
el.rows = numLines;
}
el.style.overflowX = el.scrollWidth > el.clientWidth ? '' : 'hidden';

View File

@ -2,7 +2,7 @@
/**
Copied from https://github.com/violentmonkey/violentmonkey/blob/master/src/common/util.js
A couple of trivial changes: switched to Math.sign, removed the default radix from parseInt
and switched to Math.sign
*/
/* exported compareVersion */
@ -35,7 +35,7 @@ function compareVersionChunk(ver1, ver2, isSemverMode) {
? a - b
: a > b || a < b && -1;
} else {
delta = (parseInt(a) || 0) - (parseInt(b) || 0);
delta = (parseInt(a, 10) || 0) - (parseInt(b, 10) || 0);
}
}
return delta || isSemverMode && (len1 - len2);

View File

@ -21,7 +21,7 @@
waitForTabUrl
*/
const CHROME = Boolean(chrome.app) && parseInt(navigator.userAgent.match(/Chrom\w+\/(\d+)|$/)[1]);
const CHROME = Boolean(chrome.app) && Number(navigator.userAgent.match(/Chrom\w+\/(\d+)|$/)[1]);
const OPERA = Boolean(chrome.app) && parseFloat(navigator.userAgent.match(/\bOPR\/(\d+\.\d+)|$/)[1]);
const VIVALDI = Boolean(chrome.app) && navigator.userAgent.includes('Vivaldi');
let FIREFOX = !chrome.app && parseFloat(navigator.userAgent.match(/\bFirefox\/(\d+\.\d+)|$/)[1]);
@ -81,7 +81,7 @@ const URLS = {
extractUsoArchiveId: url =>
url &&
url.startsWith(URLS.usoArchiveRaw) &&
parseInt(url.match(/\/(\d+)\.user\.css|$/)[1]),
Number(url.match(/\/(\d+)\.user\.css|$/)[1]),
extractUsoArchiveInstallUrl: url => {
const id = URLS.extractUsoArchiveId(url);
return id ? `${URLS.usoArchive}?style=${id}` : '';

View File

@ -517,7 +517,7 @@
}
function calcUsoId({md5Url: m, updateUrl}) {
return parseInt(m && m.match(/\d+|$/)[0]) ||
return Number(m && m.match(/\d+|$/)[0]) ||
URLS.extractUsoArchiveId(updateUrl);
}