@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 1.57 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/tools/wac-cli/src/upgrade/error-updaters/only-arrow-functions-updater.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,qBAAa,yBAA0B,YAAW,OAAO;IACrD;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CAWvE","file":"only-arrow-functions-updater.d.ts","sourcesContent":["import { Common, ResolveState } from '../../common';\r\nimport { ErrorResult } from '../models/error-result';\r\nimport { Updater } from '../models/updater-interface';\r\n\r\nexport class OnlyArrowFunctionsUpdater implements Updater {\r\n /**\r\n * Resolves only-arrow-functions linter error\r\n * @param {string} fileData String contents of file containing linter error\r\n * @param {ErrorResult} error Object representing linter error\r\n * @returns {Promise<string>} Updated file content after resolving linter error or the original contents if unable to resolve\r\n */\r\n public update(fileData: string, error: ErrorResult): Promise<string> {\r\n const parameterRegex = /(?<=function\\s*\\()[^)]*/;\r\n const targetRegex = /function\\s*\\([^)]*\\)/;\r\n\r\n const parameters = fileData.match(parameterRegex);\r\n const replaceString = parameters ? parameters[0] : '';\r\n const result = Common.replaceInString(fileData, targetRegex, `(${replaceString}) =>`);\r\n\r\n error.resolved = ResolveState.Resolved;\r\n return new Promise(resolve => resolve(result));\r\n }\r\n}\r\n"]}