UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

25 lines (23 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OnlyArrowFunctionsUpdater = void 0; const common_1 = require("../../common"); class OnlyArrowFunctionsUpdater { /** * Resolves only-arrow-functions linter error * @param {string} fileData String contents of file containing linter error * @param {ErrorResult} error Object representing linter error * @returns {Promise<string>} Updated file content after resolving linter error or the original contents if unable to resolve */ update(fileData, error) { const parameterRegex = /(?<=function\s*\()[^)]*/; const targetRegex = /function\s*\([^)]*\)/; const parameters = fileData.match(parameterRegex); const replaceString = parameters ? parameters[0] : ''; const result = common_1.Common.replaceInString(fileData, targetRegex, `(${replaceString}) =>`); error.resolved = common_1.ResolveState.Resolved; return new Promise(resolve => resolve(result)); } } exports.OnlyArrowFunctionsUpdater = OnlyArrowFunctionsUpdater; //# sourceMappingURL=only-arrow-functions-updater.js.map