Files
Sebastian Poxhofer 9717259ffc refactor(oxlint): enable no-else-return and unicorn/no-lonely-if (#44553)
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>
2026-07-14 12:11:21 +00:00

48 lines
1.5 KiB
TypeScript

import { isNonEmptyString } from '@sindresorhus/is';
import { braceExpand } from 'minimatch';
import type { PlatformId } from '../constants/index.ts';
import { regEx } from '../util/regex.ts';
const configFilePatterns = [
'renovate.json{,c,5}',
'.github/renovate.json{,c,5}',
'.gitlab/renovate.json{,c,5}',
'.renovaterc',
'.renovaterc.json{,c,5}',
'package.json',
];
const configFileNames = configFilePatterns.flatMap((p) => braceExpand(p));
let userAddedConfigFileNames: string[] = [];
export function setUserConfigFileNames(fileNames: string[]): void {
userAddedConfigFileNames = fileNames;
}
export function getConfigFileNames(platform?: PlatformId): string[] {
let filteredConfigFileNames = [...configFileNames];
if (isNonEmptyString(platform)) {
const platfromRe = regEx('\\.(?<platform>.*)\\/renovate\\.json[c5]?$');
filteredConfigFileNames = configFileNames.filter((filename) => {
const matchResult = platfromRe.exec(filename);
if (!matchResult) {
return true;
}
if (matchResult?.groups?.platform === platform) {
return true;
}
return false;
});
if (!['github', 'gitlab'].includes(platform) && platform !== 'local') {
filteredConfigFileNames.push(`.${platform}/renovate.json`);
filteredConfigFileNames.push(`.${platform}/renovate.jsonc`);
filteredConfigFileNames.push(`.${platform}/renovate.json5`);
}
}
return [...userAddedConfigFileNames, ...filteredConfigFileNames];
}