UNPKG

@o3r/eslint-config-otter

Version:

Recommended eslint configuration for Otter project

36 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateEslintRecommended = updateEslintRecommended; const node_path_1 = require("node:path"); const schematics_1 = require("@o3r/schematics"); /** * Update Eslint files to new recommended names */ function updateEslintRecommended() { const configFilePattern = /^.?eslint(:?rc)?\..*/; const toReplace = { 'angular-template-recommended': /(['"](?:plugin:)?@o3r\/)template-recommended(['"])/g, 'monorepo-recommended': /(['"](?:plugin:)?@o3r\/)json-recommended(['"])/g }; const isFileToParse = (path) => configFilePattern.test((0, node_path_1.basename)(path)); return (tree) => { let files; try { files = (0, schematics_1.findFilesInTree)(tree.getDir('/'), isFileToParse); } catch { files = []; tree.visit((path) => isFileToParse(path) && files.push(tree.get(path))); } files.forEach(({ content, path }) => { const contentStr = content.toString(); const newContent = Object.entries(toReplace).reduce((acc, [rule, regexp]) => { return acc.replaceAll(regexp, `$1${rule}$2`); }, contentStr); if (contentStr !== newContent) { tree.overwrite(path, newContent); } }); }; } //# sourceMappingURL=update-configs.js.map