🔧 Update lint option

This commit is contained in:
marocchino 2025-04-11 06:51:13 +09:00
parent 1125c50abd
commit e39079643f
No known key found for this signature in database
GPG key ID: F54107506CCF18D0
6 changed files with 42 additions and 47 deletions

View file

@ -4,7 +4,7 @@ import type {
IssueComment,
ReportedContentClassifiers,
Repository,
User
User,
} from "@octokit/graphql-schema"
type CreateCommentResponse = Awaited<
@ -30,7 +30,7 @@ export async function findPreviousComment(
repo: string
},
number: number,
header: string
header: string,
): Promise<IssueComment | undefined> {
let after = null
let hasNextPage = true
@ -60,7 +60,7 @@ export async function findPreviousComment(
}
}
`,
{...repo, after, number}
{...repo, after, number},
)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const viewer = data.viewer as User
@ -70,7 +70,7 @@ export async function findPreviousComment(
(node: IssueComment | null | undefined) =>
node?.author?.login === viewer.login.replace("[bot]", "") &&
!node?.isMinimized &&
node?.body?.includes(h)
node?.body?.includes(h),
)
if (target) {
return target
@ -86,7 +86,7 @@ export async function updateComment(
id: string,
body: string,
header: string,
previousBody?: string
previousBody?: string,
): Promise<void> {
if (!body && !previousBody) return core.warning("Comment body cannot be blank")
@ -108,9 +108,9 @@ export async function updateComment(
id,
body: previousBody
? bodyWithHeader(`${rawPreviousBody}\n${body}`, header)
: bodyWithHeader(body, header)
}
}
: bodyWithHeader(body, header),
},
},
)
}
export async function createComment(
@ -122,7 +122,7 @@ export async function createComment(
issue_number: number,
body: string,
header: string,
previousBody?: string
previousBody?: string,
): Promise<CreateCommentResponse | undefined> {
if (!body && !previousBody) {
core.warning("Comment body cannot be blank")
@ -132,12 +132,12 @@ export async function createComment(
return await octokit.rest.issues.createComment({
...repo,
issue_number,
body: previousBody ? `${previousBody}\n${body}` : bodyWithHeader(body, header)
body: previousBody ? `${previousBody}\n${body}` : bodyWithHeader(body, header),
})
}
export async function deleteComment(
octokit: InstanceType<typeof GitHub>,
id: string
id: string,
): Promise<void> {
await octokit.graphql(
`
@ -147,13 +147,13 @@ export async function deleteComment(
}
}
`,
{id}
{id},
)
}
export async function minimizeComment(
octokit: InstanceType<typeof GitHub>,
subjectId: string,
classifier: ReportedContentClassifiers
classifier: ReportedContentClassifiers,
): Promise<void> {
await octokit.graphql(
`
@ -163,14 +163,14 @@ export async function minimizeComment(
}
}
`,
{input: {subjectId, classifier}}
{input: {subjectId, classifier}},
)
}
export function getBodyOf(
previous: {body?: string},
append: boolean,
hideDetails: boolean
hideDetails: boolean,
): string | undefined {
if (!append) {
return undefined

View file

@ -11,48 +11,48 @@ export const repo = buildRepo()
export const header = core.getInput("header", {required: false})
export const append = core.getBooleanInput("append", {required: true})
export const hideDetails = core.getBooleanInput("hide_details", {
required: true
required: true,
})
export const recreate = core.getBooleanInput("recreate", {required: true})
export const hideAndRecreate = core.getBooleanInput("hide_and_recreate", {
required: true
required: true,
})
export const hideClassify = core.getInput("hide_classify", {
required: true
required: true,
}) as ReportedContentClassifiers
export const deleteOldComment = core.getBooleanInput("delete", {required: true})
export const onlyCreateComment = core.getBooleanInput("only_create", {
required: true
required: true,
})
export const onlyUpdateComment = core.getBooleanInput("only_update", {
required: true
required: true,
})
export const skipUnchanged = core.getBooleanInput("skip_unchanged", {
required: true
required: true,
})
export const hideOldComment = core.getBooleanInput("hide", {required: true})
export const githubToken = core.getInput("GITHUB_TOKEN", {required: true})
export const ignoreEmpty = core.getBooleanInput("ignore_empty", {
required: true
required: true,
})
function buildRepo(): {repo: string; owner: string} {
return {
owner: core.getInput("owner", {required: false}) || context.repo.owner,
repo: core.getInput("repo", {required: false}) || context.repo.repo
repo: core.getInput("repo", {required: false}) || context.repo.repo,
}
}
export async function getBody(): Promise<string> {
const pathInput = core.getMultilineInput("path", {required: false})
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
required: true
required: true,
})
if (pathInput && pathInput.length > 0) {
try {
const globber = await create(pathInput.join("\n"), {
followSymbolicLinks,
matchDirectories: false
matchDirectories: false,
})
return (await globber.glob()).map(path => readFileSync(path, "utf-8")).join("\n")
} catch (error) {

View file

@ -7,7 +7,7 @@ import {
findPreviousComment,
getBodyOf,
minimizeComment,
updateComment
updateComment,
} from "./comment"
import {
append,
@ -25,7 +25,7 @@ import {
pullRequestNumber,
recreate,
repo,
skipUnchanged
skipUnchanged,
} from "./config"
async function run(): Promise<undefined> {
@ -104,7 +104,7 @@ async function run(): Promise<undefined> {
pullRequestNumber,
body,
header,
previousBody
previousBody,
)
core.setOutput("created_comment_id", created?.data.id)
return