mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
9717259ffc
Enable no-else-return (with allowElseIf: false) and unicorn/no-lonely-if as errors in .oxlintrc.json and fix all 131 pre-existing violations (91 no-else-return, 40 unicorn/no-lonely-if) across 98 files. The no-else-return violations were fixed with the oxlint autofix (iterated to a fixpoint, plus two else-if chains that required --fix-dangerously) followed by Prettier formatting. One comment dropped by the autofix in lib/modules/manager/pub/artifacts.ts was restored manually. The unicorn/no-lonely-if violations were merged by hand, preserving comments and coverage-ignore hints. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import type { PackageDependency, PackageFileContent } from '../types.ts';
|
|
import { parse } from './parser.ts';
|
|
import { dockerRules } from './rules/docker.ts';
|
|
import { gitRules } from './rules/git.ts';
|
|
import { goRules } from './rules/go.ts';
|
|
import { extractDepsFromFragment } from './rules/index.ts';
|
|
import { ociRules } from './rules/oci.ts';
|
|
import type { RecordFragment } from './types.ts';
|
|
|
|
export function extractPackageFile(
|
|
content: string,
|
|
packageFile: string,
|
|
): PackageFileContent | null {
|
|
const deps: PackageDependency[] = [];
|
|
|
|
const fragments: RecordFragment[] | null = parse(content, packageFile);
|
|
if (!fragments) {
|
|
return null;
|
|
}
|
|
|
|
for (let idx = 0; idx < fragments.length; idx += 1) {
|
|
const fragment = fragments[idx];
|
|
for (const dep of extractDepsFromFragment(fragment)) {
|
|
dep.managerData = { idx };
|
|
|
|
// Selectively provide `replaceString` in order to make auto-replace
|
|
// functionality work correctly.
|
|
const rules = [...dockerRules, ...ociRules, ...gitRules, ...goRules];
|
|
const replaceString = fragment.value;
|
|
if (
|
|
rules.some((rule) => replaceString.startsWith(rule)) &&
|
|
dep.currentValue &&
|
|
dep.currentDigest
|
|
) {
|
|
dep.replaceString = replaceString;
|
|
}
|
|
|
|
deps.push(dep);
|
|
}
|
|
}
|
|
|
|
return deps.length ? { deps } : null;
|
|
}
|