mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-24 22:48:06 +00:00
e0cec3dc95
feat(lint): add `types-location` rule and enable it for `lib/modules`
Reviewers consistently ask for exported types to be moved into a
colocated `types.ts`. Add a `renovate/types-location` oxlint rule that
reports `export interface` / `export type` declarations outside such a
file, and turn it on across `lib/modules`.
Re-exports (`export type { X }`, `export type *`), file-local types, and
values (enums, classes, functions) are left alone. `schema.ts` files and
`schema/` directories are excluded via config, matching how
`zod-schema-location` is configured — inferred types belong next to the
schema they are derived from.
Relocating the 87 existing violations means:
- new `types.ts` files for the modules that had none
- `terragrunt/common.ts` folded into its `types.ts`, as it held nothing
else
- `RangeBound` in `versioning/gradle/compare.ts` un-exported, since only
a file-local interface referenced it
- `bazel-module/parser/fragments.ts` split from its inferred types, which
now live in `parser/types.ts` and infer through a namespace import so
each schema keeps its merged name
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { regEx } from '../../../util/regex.ts';
|
|
import type { ParsedManifestUrl } from './types.ts';
|
|
|
|
/**
|
|
* Parse a Rust manifest URL to extract the release date and version identifier.
|
|
*
|
|
* Supports the format: .../YYYY-MM-DD/channel-rust-{identifier}.toml
|
|
*
|
|
* @param url - The manifest URL to parse
|
|
* @returns Parsed manifest data, or null if the URL is invalid
|
|
*
|
|
* @example
|
|
* parseManifestUrl('static.rust-lang.org/dist/2025-11-24/channel-rust-nightly.toml')
|
|
* // { date: '2025-11-24', version: 'nightly' }
|
|
*
|
|
* parseManifestUrl('static.rust-lang.org/dist/2024-10-17/channel-rust-1.82.0.toml')
|
|
* // { date: '2024-10-17', version: '1.82.0' }
|
|
*
|
|
* parseManifestUrl('invalid-url')
|
|
* // null
|
|
*/
|
|
export function parseManifestUrl(url: string): ParsedManifestUrl | null {
|
|
// Permissive regex to extract date and version from manifest URLs
|
|
// Matches: .../YYYY-MM-DD/channel-rust-{identifier}.toml
|
|
const pattern = regEx(
|
|
/(?<date>\d{4}-\d{2}-\d{2})\/channel-rust-(?<version>.+?)\.toml$/,
|
|
);
|
|
|
|
const match = pattern.exec(url);
|
|
if (!match?.groups) {
|
|
return null;
|
|
}
|
|
|
|
const { date, version } = match.groups;
|
|
|
|
return { date, version };
|
|
}
|