[linter] Turn on require-yield, no-useless-escape

This commit is contained in:
Sergey Konovalov
2025-08-31 01:34:22 +03:00
parent 1b0b2c2c5b
commit 988b6d6d78
5 changed files with 33 additions and 18 deletions

View File

@ -469,14 +469,17 @@ function healthCheckRabbit(taskqueue) {
return !!exchange; return !!exchange;
}); });
} }
/**
* Check ActiveMQ connection health without using a generator.
* @param {TaskQueueRabbitMQ} taskqueue - Queue instance holding the connection
* @returns {Promise<boolean>} true if connection is open
*/
function healthCheckActive(taskqueue) { function healthCheckActive(taskqueue) {
return co(function* () { // todo better check
//todo better check if (!taskqueue.connection) {
if (!taskqueue.connection) { return Promise.resolve(false);
return false; }
} return Promise.resolve(taskqueue.connection.is_open());
return taskqueue.connection.is_open();
});
} }
function initSenderActive(sender, senderData) { function initSenderActive(sender, senderData) {

View File

@ -67,7 +67,7 @@ function getTenant(ctx, domain) {
let tenant = getDefautTenant(); let tenant = getDefautTenant();
if (domain) { if (domain) {
//remove port //remove port
domain = domain.replace(/\:.*$/, ''); domain = domain.replace(/:.*$/, '');
if (cfgTenantsBaseDomain && domain.endsWith('.' + cfgTenantsBaseDomain)) { if (cfgTenantsBaseDomain && domain.endsWith('.' + cfgTenantsBaseDomain)) {
tenant = domain.substring(0, domain.length - cfgTenantsBaseDomain.length - 1); tenant = domain.substring(0, domain.length - cfgTenantsBaseDomain.length - 1);

View File

@ -2272,7 +2272,13 @@ exports.install = function (server, callbackFunction) {
return result; return result;
} }
function* setLockDocumentTimer(ctx, docId, userId) { /**
* Schedule lock cleanup for a document after the configured timeout.
* @param {operationContext} ctx - Operation context
* @param {string} docId - Document identifier
* @param {string} userId - User identifier associated with the lock
*/
function setLockDocumentTimer(ctx, docId, userId) {
const tenExpLockDoc = ctx.getCfg('services.CoAuthoring.expire.lockDoc', cfgExpLockDoc); const tenExpLockDoc = ctx.getCfg('services.CoAuthoring.expire.lockDoc', cfgExpLockDoc);
const timerId = setTimeout(() => { const timerId = setTimeout(() => {
return co(function* () { return co(function* () {
@ -3180,7 +3186,7 @@ exports.install = function (server, callbackFunction) {
if (lockDocumentTimer) { if (lockDocumentTimer) {
cleanLockDocumentTimer(docId, lockDocumentTimer); cleanLockDocumentTimer(docId, lockDocumentTimer);
} }
yield* setLockDocumentTimer(ctx, docId, lockDocument.id); setLockDocumentTimer(ctx, docId, lockDocument.id);
} }
} }
if (constants.CONN_CLOSED === conn.conn.readyState) { if (constants.CONN_CLOSED === conn.conn.readyState) {
@ -3955,7 +3961,7 @@ exports.install = function (server, callbackFunction) {
if (lockDocumentTimer) { if (lockDocumentTimer) {
ctx.logger.debug('lockDocumentsTimerId update c_oPublishType.changes'); ctx.logger.debug('lockDocumentsTimerId update c_oPublishType.changes');
cleanLockDocumentTimer(data.docId, lockDocumentTimer); cleanLockDocumentTimer(data.docId, lockDocumentTimer);
yield* setLockDocumentTimer(ctx, data.docId, lockDocumentTimer.userId); setLockDocumentTimer(ctx, data.docId, lockDocumentTimer.userId);
} }
participants = getParticipants(data.docId, true, data.userId); participants = getParticipants(data.docId, true, data.userId);
if (participants.length > 0) { if (participants.length > 0) {
@ -3985,7 +3991,7 @@ exports.install = function (server, callbackFunction) {
if (lockDocumentTimer) { if (lockDocumentTimer) {
ctx.logger.debug('lockDocumentsTimerId update c_oPublishType.changesNotify'); ctx.logger.debug('lockDocumentsTimerId update c_oPublishType.changesNotify');
cleanLockDocumentTimer(data.docId, lockDocumentTimer); cleanLockDocumentTimer(data.docId, lockDocumentTimer);
yield* setLockDocumentTimer(ctx, data.docId, lockDocumentTimer.userId); setLockDocumentTimer(ctx, data.docId, lockDocumentTimer.userId);
} }
break; break;
case commonDefines.c_oPublishType.auth: case commonDefines.c_oPublishType.auth:

View File

@ -324,9 +324,9 @@ TaskQueueDataConvert.prototype = {
serializeXmlAttr(name, value) { serializeXmlAttr(name, value) {
let xml = ''; let xml = '';
if (null != value) { if (null != value) {
xml += ' ' + name + '=\"'; xml += ' ' + name + '="';
xml += utils.encodeXml(value.toString()); xml += utils.encodeXml(value.toString());
xml += '\"'; xml += '"';
} }
return xml; return xml;
} }
@ -375,7 +375,14 @@ async function changeFormatToExtendedPdf(ctx, dataConvert, cmd) {
} }
} }
} }
function* replaceEmptyFile(ctx, fileFrom, ext, _lcid) { /**
* Replace an empty file with a localized template of the requested format, if available.
* @param {operationContext} ctx - Operation context for config and logging
* @param {string} fileFrom - Path to the file to check/replace
* @param {string} ext - Target extension (e.g., 'docx', 'xlsx', 'pptx')
* @param {number} _lcid - Optional locale identifier to select template locale
*/
function replaceEmptyFile(ctx, fileFrom, ext, _lcid) {
const tenNewFileTemplate = ctx.getCfg('services.CoAuthoring.server.newFileTemplate', cfgNewFileTemplate); const tenNewFileTemplate = ctx.getCfg('services.CoAuthoring.server.newFileTemplate', cfgNewFileTemplate);
if (!fs.existsSync(fileFrom) || 0 === fs.lstatSync(fileFrom).size) { if (!fs.existsSync(fileFrom) || 0 === fs.lstatSync(fileFrom).size) {
let locale = constants.TEMPLATES_DEFAULT_LOCALE; let locale = constants.TEMPLATES_DEFAULT_LOCALE;
@ -1115,7 +1122,7 @@ function* ExecuteTask(ctx, task) {
error = yield* downloadFile(ctx, url, dataConvert.fileFrom, withAuthorization, isInJwtToken, headers); error = yield* downloadFile(ctx, url, dataConvert.fileFrom, withAuthorization, isInJwtToken, headers);
} }
if (constants.NO_ERROR === error) { if (constants.NO_ERROR === error) {
yield* replaceEmptyFile(ctx, dataConvert.fileFrom, format, cmd.getLCID()); replaceEmptyFile(ctx, dataConvert.fileFrom, format, cmd.getLCID());
} }
if (clientStatsD) { if (clientStatsD) {
clientStatsD.timing('conv.downloadFile', new Date() - curDate); clientStatsD.timing('conv.downloadFile', new Date() - curDate);

View File

@ -53,8 +53,7 @@ module.exports = [
'no-console': 'off', // Allow console in server code 'no-console': 'off', // Allow console in server code
'no-continue': 'off', // Allow continue statements 'no-continue': 'off', // Allow continue statements
'no-plusplus': 'off', 'no-plusplus': 'off',
'require-yield': 'off',
'no-useless-escape': 'off',
// Modern JavaScript practices // Modern JavaScript practices
'prefer-const': 'error', // Enforce const for immutable bindings 'prefer-const': 'error', // Enforce const for immutable bindings
'no-var': 'error', // Enforce let/const over var 'no-var': 'error', // Enforce let/const over var