mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 07:20:39 +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
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { regEx } from '../../../util/regex.ts';
|
|
import { GenericVersioningApi } from '../generic.ts';
|
|
import type { GenericVersion, VersioningApi } from '../types.ts';
|
|
|
|
export const id = 'unity3d';
|
|
export const displayName = 'Unity3D';
|
|
export const urls = [
|
|
'[Unity version define expressions](https://docs.unity3d.com/Manual/assembly-definition-includes.html#version-define-expressions)',
|
|
];
|
|
export const supportsRanges = false;
|
|
|
|
class Unity3dVersioningApi extends GenericVersioningApi {
|
|
private static readonly parsingRegex = regEx(
|
|
/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?<releaseStream>\w)(?<build>\d+)/,
|
|
);
|
|
|
|
private static readonly ReleaseStreamType = [
|
|
'a', // Alpha
|
|
'b', // Beta
|
|
'p', // Patch
|
|
'x', // Experimental
|
|
'f', // Stable
|
|
'c', // Stable (China)
|
|
];
|
|
private static readonly stableVersions = ['f', 'c'];
|
|
|
|
protected _parse(version: string): GenericVersion | null {
|
|
const matches = Unity3dVersioningApi.parsingRegex.exec(version);
|
|
if (!matches?.groups) {
|
|
return null;
|
|
}
|
|
const { major, minor, patch, releaseStream, build } = matches.groups;
|
|
|
|
const release = [
|
|
parseInt(major, 10),
|
|
parseInt(minor, 10),
|
|
parseInt(patch, 10),
|
|
Unity3dVersioningApi.ReleaseStreamType.indexOf(releaseStream),
|
|
parseInt(build, 10),
|
|
];
|
|
const isStable =
|
|
Unity3dVersioningApi.stableVersions.includes(releaseStream);
|
|
|
|
return { release, prerelease: isStable ? undefined : build };
|
|
}
|
|
}
|
|
|
|
export const api: VersioningApi = new Unity3dVersioningApi();
|
|
|
|
export default api;
|