From 9a02d4b34400593cef309b427b3e170c643b5ef0 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 22 Mar 2024 23:25:07 +0100 Subject: [PATCH] Fix eslint warnings and errors --- .../file/checkFileNameIncludes/2.0.0/index.js | 14 ++++++++------ .../file/checkFileNameIncludes/2.0.0/index.ts | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.js index eb86c17..9e1ff36 100644 --- a/FlowPlugins/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.js @@ -38,7 +38,7 @@ var details = function () { return ({ type: 'text', }, // eslint-disable-next-line no-template-curly-in-string - tooltip: 'Specify the pattern (regex) to check for in file name e.g. ^Pattern*\.mkv$', + tooltip: 'Specify the pattern (regex) to check for in file name e.g. ^Pattern.*mkv$', }, { label: 'Include file directory in check', @@ -51,7 +51,7 @@ var details = function () { return ({ }, // eslint-disable-next-line no-template-curly-in-string tooltip: 'Should the terms and patterns be evaluated against the file directory e.g. false, true', - } + }, ], outputs: [ { @@ -70,19 +70,21 @@ var plugin = function (args) { var lib = require('../../../../../methods/lib')(); // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign args.inputs = lib.loadDefaultValues(args.inputs, details); - var buildArrayInput = function (arrayInput) { var _a, _b; return (_b = (_a = String(arrayInput)) === null || _a === void 0 ? void 0 : _a.trim().split(',')) !== null && _b !== void 0 ? _b : new Array(); }; + var buildArrayInput = function (arrayInput) { var _a, _b; return (_b = (_a = String(arrayInput)) === null || _a === void 0 ? void 0 : _a.trim().split(',')) !== null && _b !== void 0 ? _b : []; }; var isAMatch = false; - var fileName = "".concat(Boolean(args.inputs.includeFileDirectory) ? (0, fileUtils_1.getFileAbosluteDir)(args.inputFileObj._id) + '/' : '').concat((0, fileUtils_1.getFileName)(args.inputFileObj._id), ".").concat((0, fileUtils_1.getContainer)(args.inputFileObj._id)); + var fileName = "".concat((args.inputs.includeFileDirectory ? "".concat((0, fileUtils_1.getFileAbosluteDir)(args.inputFileObj._id), "/") : '') + + (0, fileUtils_1.getFileName)(args.inputFileObj._id), ".").concat((0, fileUtils_1.getContainer)(args.inputFileObj._id)); var searchCriteriasArray = buildArrayInput(args.inputs.terms) - .map(function (term) { return term.replace(/[\-\/\\^$*+?.()|[\]{}]/g, '\\$&'); }); // https://github.com/tc39/proposal-regex-escaping + .map(function (term) { return term.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); }); // https://github.com/tc39/proposal-regex-escaping if (args.inputs.pattern) searchCriteriasArray.push(String(args.inputs.pattern)); - for (var i = 0; i < searchCriteriasArray.length; i++) + for (var i = 0; i < searchCriteriasArray.length; i++) { if (new RegExp(searchCriteriasArray[i]).test(fileName)) { isAMatch = true; args.jobLog("'".concat(fileName, "' includes '").concat(searchCriteriasArray[i], "'")); break; } + } return { outputFileObj: args.inputFileObj, outputNumber: isAMatch ? 1 : 2, diff --git a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.ts index 30d6aae..f3aedaa 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileNameIncludes/2.0.0/index.ts @@ -41,7 +41,7 @@ const details = (): IpluginDetails => ({ type: 'text', }, // eslint-disable-next-line no-template-curly-in-string - tooltip: 'Specify the pattern (regex) to check for in file name e.g. ^Pattern*\.mkv$', + tooltip: 'Specify the pattern (regex) to check for in file name e.g. ^Pattern.*mkv$', }, { label: 'Include file directory in check', @@ -54,7 +54,7 @@ const details = (): IpluginDetails => ({ }, // eslint-disable-next-line no-template-curly-in-string tooltip: 'Should the terms and patterns be evaluated against the file directory e.g. false, true', - } + }, ], outputs: [ { @@ -74,22 +74,23 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => { // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign args.inputs = lib.loadDefaultValues(args.inputs, details); - const buildArrayInput = (arrayInput: any): string[] => - String(arrayInput)?.trim().split(',') ?? new Array(); + const buildArrayInput = (arrayInput: unknown): string[] => String(arrayInput)?.trim().split(',') ?? []; let isAMatch = false; - const fileName = `${Boolean(args.inputs.includeFileDirectory) ? getFileAbosluteDir(args.inputFileObj._id) + '/' : ''}${getFileName(args.inputFileObj._id)}.${getContainer(args.inputFileObj._id)}`; + const fileName = `${(args.inputs.includeFileDirectory ? `${getFileAbosluteDir(args.inputFileObj._id)}/` : '') + + getFileName(args.inputFileObj._id) + }.${getContainer(args.inputFileObj._id)}`; const searchCriteriasArray = buildArrayInput(args.inputs.terms) - .map(term => term.replace(/[\-\/\\^$*+?.()|[\]{}]/g, '\\$&')); // https://github.com/tc39/proposal-regex-escaping - if (args.inputs.pattern) - searchCriteriasArray.push(String(args.inputs.pattern)); + .map((term) => term.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')); // https://github.com/tc39/proposal-regex-escaping + if (args.inputs.pattern) searchCriteriasArray.push(String(args.inputs.pattern)); - for (let i = 0; i < searchCriteriasArray.length; i++) + for (let i = 0; i < searchCriteriasArray.length; i++) { if (new RegExp(searchCriteriasArray[i]).test(fileName)) { isAMatch = true; args.jobLog(`'${fileName}' includes '${searchCriteriasArray[i]}'`); break; } + } return { outputFileObj: args.inputFileObj,