mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-02 14:38:47 +00:00
refactor: enhance ESLint configuration and type safety
This commit replaces `.eslintrc.yml` with `eslint.config.mts`, and updates the ESLint setup with Noir and Flat Gitignore configs. Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
32 files changed
+1140
-752
No files matched your search
+1
-1
@@ -29,7 +29,7 @@ export * from "./input.js";
|
||||
export * from "./octokit.js";
|
||||
export * from "./output.js";
|
||||
export * from "./parse-commit-message.js";
|
||||
export * from "./parse-semver.js";
|
||||
export * from "./parse-semantic-version.js";
|
||||
export * from "./repository.js";
|
||||
export * from "./sha.js";
|
||||
export * from "./trim.js";
|
||||
+4
-2
@@ -25,10 +25,10 @@
|
||||
import { getInput } from "@actions/core";
|
||||
import { cache } from "./cache.js";
|
||||
|
||||
export function input<T = string>(
|
||||
export function input(
|
||||
name: string,
|
||||
required?: boolean,
|
||||
): T;
|
||||
): string;
|
||||
export function input<T = string>(
|
||||
name: string,
|
||||
parser: (value: string) => T,
|
||||
@@ -36,12 +36,14 @@ export function input<T = string>(
|
||||
): T;
|
||||
export function input<T = string>(
|
||||
name: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
parser: boolean | ((value: string) => T) = (value): T => value as T,
|
||||
required = true,
|
||||
): T {
|
||||
if (typeof parser === "boolean") {
|
||||
required = parser;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
parser = (value): T => value as T;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
import { getOctokit } from "@actions/github";
|
||||
import { type GitHub } from "@actions/github/lib/utils.js";
|
||||
import { gitHubToken } from "../inputs/index.js";
|
||||
import { cache } from "./cache.js";
|
||||
import { gitHubToken } from "../inputs/index.js";
|
||||
|
||||
export function octokit(): InstanceType<typeof GitHub> {
|
||||
return cache("octokit", () => getOctokit(gitHubToken()));
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
const REGEX = /^(?<type>[^!:() ]*)(?:\((?<scope>[^!()]*?)\)|)(?<breaking>!?): *(?<description>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
|
||||
const REGEX = /^(?<type>[^ !():]*)(?:\((?<scope>[^!()]*?)\)|)(?<breaking>!?): *(?<description>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
|
||||
|
||||
export function parseCommitMessage(message: string): ParsedCommitMessageI {
|
||||
const { description, flag, pr, scope, type, breaking } = REGEX.exec(message)?.groups ?? {};
|
||||
@@ -39,9 +39,14 @@ export function parseCommitMessage(message: string): ParsedCommitMessageI {
|
||||
|
||||
export interface ParsedCommitMessageI {
|
||||
breaking: boolean;
|
||||
|
||||
description?: string;
|
||||
|
||||
flag?: string;
|
||||
|
||||
pr?: string;
|
||||
|
||||
scope?: string;
|
||||
|
||||
type?: string;
|
||||
}
|
||||
@@ -22,11 +22,12 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import { parse, type SemVer } from "semver";
|
||||
import { releaseName, releaseNamePrefix } from "../inputs/index.js";
|
||||
import { type SemVer, parse } from "semver";
|
||||
import { cache } from "./cache.js";
|
||||
import { releaseName, releaseNamePrefix } from "../inputs/index.js";
|
||||
|
||||
export function parseSemVer(version = releaseName()): SemVer | null {
|
||||
export function parseSemanticVersion(version = releaseName()): SemVer | null {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
return cache(`semver-${ version }`, () => parse(version.replace(new RegExp(`^${ releaseNamePrefix() }`), ""), { includePrerelease: true } as never));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,15 @@
|
||||
import { context } from "@actions/github";
|
||||
import { cache } from "./cache.js";
|
||||
|
||||
export function repository(): { owner: string; repo: string; url: string } {
|
||||
export interface TRepository {
|
||||
owner: string;
|
||||
|
||||
repo: string;
|
||||
|
||||
url: string;
|
||||
}
|
||||
|
||||
export function repository(): TRepository {
|
||||
return cache("repo", () => {
|
||||
const { repo: { owner, repo }, serverUrl } = context;
|
||||
|
||||
|
||||
+2
-1
@@ -25,5 +25,6 @@
|
||||
export function trim<T extends string | null | undefined>(value: T): T {
|
||||
if (!value) return value;
|
||||
|
||||
return value.trim().replace(/ {2,}/g, " ") as T;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
return value.trim().replaceAll(/ {2,}/g, " ") as T;
|
||||
}
|
||||
Reference in new issue
Block a user