mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[linter] Turn on no-prototype-builtins
This commit is contained in:
@ -339,39 +339,39 @@ async function readLicenseTenant(ctx, licenseFile, baseVerifiedLicense) {
|
||||
if (true === oLicense['timelimited']) {
|
||||
res.mode |= c_LM.Limited;
|
||||
}
|
||||
if (oLicense.hasOwnProperty('trial')) {
|
||||
if (oLicense.hasOwn('trial')) {
|
||||
res.mode |= true === oLicense['trial'] || 'true' === oLicense['trial'] || 'True' === oLicense['trial'] ? c_LM.Trial : c_LM.None; // Someone who likes to put json string instead of bool
|
||||
}
|
||||
if (true === oLicense['developer']) {
|
||||
res.mode |= c_LM.Developer;
|
||||
}
|
||||
if (oLicense.hasOwnProperty('branding')) {
|
||||
if (oLicense.hasOwn('branding')) {
|
||||
res.branding = true === oLicense['branding'] || 'true' === oLicense['branding'] || 'True' === oLicense['branding']; // Someone who likes to put json string instead of bool
|
||||
}
|
||||
if (oLicense.hasOwnProperty('customization')) {
|
||||
if (oLicense.hasOwn('customization')) {
|
||||
res.customization = !!oLicense['customization'];
|
||||
}
|
||||
if (oLicense.hasOwnProperty('advanced_api')) {
|
||||
if (oLicense.hasOwn('advanced_api')) {
|
||||
res.advancedApi = !!oLicense['advanced_api'];
|
||||
}
|
||||
if (oLicense.hasOwnProperty('connections')) {
|
||||
if (oLicense.hasOwn('connections')) {
|
||||
res.connections = oLicense['connections'] >> 0;
|
||||
}
|
||||
if (oLicense.hasOwnProperty('connections_view')) {
|
||||
if (oLicense.hasOwn('connections_view')) {
|
||||
res.connectionsView = oLicense['connections_view'] >> 0;
|
||||
}
|
||||
if (oLicense.hasOwnProperty('users_count')) {
|
||||
if (oLicense.hasOwn('users_count')) {
|
||||
res.usersCount = oLicense['users_count'] >> 0;
|
||||
}
|
||||
if (oLicense.hasOwnProperty('users_view_count')) {
|
||||
if (oLicense.hasOwn('users_view_count')) {
|
||||
res.usersViewCount = oLicense['users_view_count'] >> 0;
|
||||
}
|
||||
if (oLicense.hasOwnProperty('users_expire')) {
|
||||
if (oLicense.hasOwn('users_expire')) {
|
||||
res.usersExpire = Math.max(constants.LICENSE_EXPIRE_USERS_ONE_DAY, (oLicense['users_expire'] >> 0) * constants.LICENSE_EXPIRE_USERS_ONE_DAY);
|
||||
}
|
||||
|
||||
// Read grace_days setting from license file if available
|
||||
if (oLicense.hasOwnProperty('grace_days')) {
|
||||
if (oLicense.hasOwn('grace_days')) {
|
||||
res.graceDays = Math.max(0, oLicense['grace_days'] >> 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1033,7 +1033,7 @@ function checkClientIp(req, res, next) {
|
||||
exports.checkClientIp = checkClientIp;
|
||||
function lowercaseQueryString(req, res, next) {
|
||||
for (var key in req.query) {
|
||||
if (req.query.hasOwnProperty(key) && key.toLowerCase() !== key) {
|
||||
if (req.query.hasOwn(key) && key.toLowerCase() !== key) {
|
||||
req.query[key.toLowerCase()] = req.query[key];
|
||||
delete req.query[key];
|
||||
}
|
||||
|
||||
@ -736,7 +736,7 @@ async function getOriginalParticipantsId(ctx, docId) {
|
||||
}
|
||||
}
|
||||
for (var name in tmpObject) {
|
||||
if (tmpObject.hasOwnProperty(name)) {
|
||||
if (tmpObject.hasOwn(name)) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
@ -2366,13 +2366,13 @@ exports.install = function (server, callbackFunction) {
|
||||
|
||||
oRangeOrObjectId = element['rangeOrObjectId'];
|
||||
|
||||
if (oRecalcIndexColumns && oRecalcIndexColumns.hasOwnProperty(sheetId)) {
|
||||
if (oRecalcIndexColumns && oRecalcIndexColumns.hasOwn(sheetId)) {
|
||||
// Column index recalculation
|
||||
oRangeOrObjectId['c1'] = oRecalcIndexColumns[sheetId].getLockMe2(oRangeOrObjectId['c1']);
|
||||
oRangeOrObjectId['c2'] = oRecalcIndexColumns[sheetId].getLockMe2(oRangeOrObjectId['c2']);
|
||||
isModify = true;
|
||||
}
|
||||
if (oRecalcIndexRows && oRecalcIndexRows.hasOwnProperty(sheetId)) {
|
||||
if (oRecalcIndexRows && oRecalcIndexRows.hasOwn(sheetId)) {
|
||||
// row index recalculation
|
||||
oRangeOrObjectId['r1'] = oRecalcIndexRows[sheetId].getLockMe2(oRangeOrObjectId['r1']);
|
||||
oRangeOrObjectId['r2'] = oRecalcIndexRows[sheetId].getLockMe2(oRangeOrObjectId['r2']);
|
||||
@ -2395,8 +2395,8 @@ exports.install = function (server, callbackFunction) {
|
||||
var oRecalcIndexResult = {};
|
||||
|
||||
for (var sheetId in oRecalcIndex) {
|
||||
if (oRecalcIndex.hasOwnProperty(sheetId)) {
|
||||
if (!oRecalcIndexResult.hasOwnProperty(sheetId)) {
|
||||
if (oRecalcIndex.hasOwn(sheetId)) {
|
||||
if (!oRecalcIndexResult.hasOwn(sheetId)) {
|
||||
oRecalcIndexResult[sheetId] = new CRecalcIndex();
|
||||
}
|
||||
for (; nIndex < oRecalcIndex[sheetId]._arrElements.length; ++nIndex) {
|
||||
@ -4217,7 +4217,7 @@ exports.install = function (server, callbackFunction) {
|
||||
}
|
||||
}
|
||||
for (const tenantId in tenants) {
|
||||
if (tenants.hasOwnProperty(tenantId)) {
|
||||
if (tenants.hasOwn(tenantId)) {
|
||||
ctx.setTenant(tenantId);
|
||||
const tenant = tenants[tenantId];
|
||||
yield* collectStats(ctx, tenant.countEditByShard, tenant.countLiveViewByShard, tenant.countViewByShard);
|
||||
@ -4547,13 +4547,13 @@ exports.licenseInfo = function (req, res) {
|
||||
const byMonthView = yield editorStat.getPresenceUniqueViewUsersOfMonth(ctx);
|
||||
const byMonthMerged = [];
|
||||
for (const i in byMonth) {
|
||||
if (byMonth.hasOwnProperty(i)) {
|
||||
if (byMonth.hasOwn(i)) {
|
||||
byMonthMerged[i] = {date: i, users: byMonth[i], usersView: {}};
|
||||
}
|
||||
}
|
||||
for (const i in byMonthView) {
|
||||
if (byMonthView.hasOwnProperty(i)) {
|
||||
if (byMonthMerged.hasOwnProperty(i)) {
|
||||
if (byMonthView.hasOwn(i)) {
|
||||
if (byMonthMerged.hasOwn(i)) {
|
||||
byMonthMerged[i].usersView = byMonthView[i];
|
||||
} else {
|
||||
byMonthMerged[i] = {date: i, users: {}, usersView: byMonthView[i]};
|
||||
|
||||
@ -783,7 +783,7 @@ function* commandImgurls(ctx, conn, cmd, outputData) {
|
||||
const ext = pathModule.extname(urlParsed.pathname).substring(1);
|
||||
const urlBasename = pathModule.basename(urlParsed.pathname);
|
||||
const displayedImageName = urlBasename.substring(0, urlBasename.length - ext.length - 1);
|
||||
if (displayedImageMap.hasOwnProperty(displayedImageName)) {
|
||||
if (displayedImageMap.hasOwn(displayedImageName)) {
|
||||
formatStr = ext;
|
||||
isAllow = true;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ exports.load = function (_collectionName, callbackFunction) {
|
||||
cursor.each((err, item) => {
|
||||
// Null denotes the last element
|
||||
if (item != null) {
|
||||
if (!result.hasOwnProperty(item.docid)) {
|
||||
if (!result.hasOwn(item.docid)) {
|
||||
result[item.docid] = [item];
|
||||
} else {
|
||||
result[item.docid].push(item);
|
||||
|
||||
@ -62,7 +62,7 @@ function columnsToLowercase(rows) {
|
||||
for (const row of rows) {
|
||||
const newRow = {};
|
||||
for (const column in row) {
|
||||
if (row.hasOwnProperty(column)) {
|
||||
if (row.hasOwn(column)) {
|
||||
newRow[column.toLowerCase()] = row[column];
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,10 +261,10 @@ EditorData.prototype.addForceSaveTimerNX = async function (ctx, docId, expireAt)
|
||||
EditorData.prototype.getForceSaveTimer = async function (now) {
|
||||
const res = [];
|
||||
for (const tenant in this.forceSaveTimer) {
|
||||
if (this.forceSaveTimer.hasOwnProperty(tenant)) {
|
||||
if (this.forceSaveTimer.hasOwn(tenant)) {
|
||||
const tenantTimer = this.forceSaveTimer[tenant];
|
||||
for (const docId in tenantTimer) {
|
||||
if (tenantTimer.hasOwnProperty(docId)) {
|
||||
if (tenantTimer.hasOwn(docId)) {
|
||||
if (tenantTimer[docId] < now) {
|
||||
res.push([tenant, docId]);
|
||||
delete tenantTimer[docId];
|
||||
@ -302,7 +302,7 @@ EditorStat.prototype.getPresenceUniqueUser = async function (ctx, nowUTC) {
|
||||
this.uniqueUser[ctx.tenant] = tenantUser = {};
|
||||
}
|
||||
for (const userId in tenantUser) {
|
||||
if (tenantUser.hasOwnProperty(userId)) {
|
||||
if (tenantUser.hasOwn(userId)) {
|
||||
if (tenantUser[userId].expireAt > nowUTC) {
|
||||
const elem = tenantUser[userId];
|
||||
const newElem = {userid: userId, expire: new Date(elem.expireAt * 1000)};
|
||||
@ -334,7 +334,7 @@ EditorStat.prototype.getPresenceUniqueUsersOfMonth = async function (ctx) {
|
||||
this.uniqueUsersOfMonth[ctx.tenant] = tenantUser = {};
|
||||
}
|
||||
for (const periodId in tenantUser) {
|
||||
if (tenantUser.hasOwnProperty(periodId)) {
|
||||
if (tenantUser.hasOwn(periodId)) {
|
||||
if (tenantUser[periodId].expireAt <= nowUTC) {
|
||||
delete tenantUser[periodId];
|
||||
} else {
|
||||
@ -360,7 +360,7 @@ EditorStat.prototype.getPresenceUniqueViewUser = async function (ctx, nowUTC) {
|
||||
this.uniqueViewUser[ctx.tenant] = tenantUser = {};
|
||||
}
|
||||
for (const userId in tenantUser) {
|
||||
if (tenantUser.hasOwnProperty(userId)) {
|
||||
if (tenantUser.hasOwn(userId)) {
|
||||
if (tenantUser[userId].expireAt > nowUTC) {
|
||||
const elem = tenantUser[userId];
|
||||
const newElem = {userid: userId, expire: new Date(elem.expireAt * 1000)};
|
||||
@ -392,7 +392,7 @@ EditorStat.prototype.getPresenceUniqueViewUsersOfMonth = async function (ctx) {
|
||||
this.uniqueViewUsersOfMonth[ctx.tenant] = tenantUser = {};
|
||||
}
|
||||
for (const periodId in tenantUser) {
|
||||
if (tenantUser.hasOwnProperty(periodId)) {
|
||||
if (tenantUser.hasOwn(periodId)) {
|
||||
if (tenantUser[periodId].expireAt <= nowUTC) {
|
||||
delete tenantUser[periodId];
|
||||
} else {
|
||||
@ -480,7 +480,7 @@ EditorStat.prototype.getShutdownCount = async function (key) {
|
||||
let count = 0;
|
||||
if (this.shutdown[key]) {
|
||||
for (const docId in this.shutdown[key]) {
|
||||
if (this.shutdown[key].hasOwnProperty(docId)) {
|
||||
if (this.shutdown[key].hasOwn(docId)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ function createCacheMiddleware(prefix, rootPath, cfgStorage, secret, rout) {
|
||||
}
|
||||
|
||||
for (const i in cfgStaticContent) {
|
||||
if (cfgStaticContent.hasOwnProperty(i)) {
|
||||
if (cfgStaticContent.hasOwn(i)) {
|
||||
router.use(i, express.static(cfgStaticContent[i]['path'], cfgStaticContent[i]['options']));
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ docsCoServer.install(server, () => {
|
||||
let themesList = [];
|
||||
|
||||
for (const i in staticContent) {
|
||||
if (staticContent.hasOwnProperty(i) && themesUri.startsWith(i)) {
|
||||
if (staticContent.hasOwn(i) && themesUri.startsWith(i)) {
|
||||
const dir = staticContent[i].path + themesUri.substring(i.length);
|
||||
themesList = yield utils.listObjects(dir, true);
|
||||
ctx.logger.debug('themes.json dir:%s', dir);
|
||||
|
||||
@ -102,7 +102,7 @@ if (!mimeDB['application/vnd.visio2013']) {
|
||||
const mimeTypesByExt = (function () {
|
||||
const mimeTypesByExt = {};
|
||||
for (const mimeType in mimeDB) {
|
||||
if (mimeDB.hasOwnProperty(mimeType)) {
|
||||
if (mimeDB.hasOwn(mimeType)) {
|
||||
const val = mimeDB[mimeType];
|
||||
if (val.extensions) {
|
||||
val.extensions.forEach(value => {
|
||||
|
||||
@ -593,7 +593,7 @@ function* concatFiles(source, template) {
|
||||
}
|
||||
}
|
||||
for (const i in writeStreams) {
|
||||
if (writeStreams.hasOwnProperty(i)) {
|
||||
if (writeStreams.hasOwn(i)) {
|
||||
writeStreams[i].end();
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,8 +63,7 @@ module.exports = [
|
||||
'no-duplicate-imports': 'error', // Avoid duplicate imports
|
||||
'no-useless-constructor': 'error', // Remove unnecessary constructors
|
||||
'no-useless-return': 'error', // Remove unnecessary return statements
|
||||
'max-lines': ['warn', 5000],
|
||||
'no-prototype-builtins': 'off'
|
||||
'max-lines': ['warn', 5000]
|
||||
}
|
||||
},
|
||||
prettier
|
||||
|
||||
Reference in New Issue
Block a user