🔧 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

@ -6,14 +6,11 @@
}, },
"formatter": { "formatter": {
"enabled": true, "enabled": true,
"useEditorconfig": true,
"formatWithErrors": false, "formatWithErrors": false,
"indentStyle": "space", "indentStyle": "space",
"indentWidth": 2, "indentWidth": 2,
"lineEnding": "lf", "lineEnding": "lf",
"lineWidth": 100, "lineWidth": 100,
"attributePosition": "auto",
"bracketSpacing": true,
"ignore": ["**/dist/", "**/lib/", "**/node_modules/"] "ignore": ["**/dist/", "**/lib/", "**/node_modules/"]
}, },
"organizeImports": { "enabled": true }, "organizeImports": { "enabled": true },
@ -92,12 +89,10 @@
"formatter": { "formatter": {
"jsxQuoteStyle": "double", "jsxQuoteStyle": "double",
"quoteProperties": "asNeeded", "quoteProperties": "asNeeded",
"trailingCommas": "none",
"semicolons": "asNeeded", "semicolons": "asNeeded",
"arrowParentheses": "asNeeded", "arrowParentheses": "asNeeded",
"bracketSameLine": false, "bracketSameLine": false,
"quoteStyle": "double", "quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": false "bracketSpacing": false
}, },
"globals": ["jest"] "globals": ["jest"]

26
dist/index.js generated vendored
View file

@ -118,8 +118,8 @@ async function updateComment(octokit, id, body, header, previousBody) {
id, id,
body: previousBody body: previousBody
? bodyWithHeader(`${rawPreviousBody}\n${body}`, header) ? bodyWithHeader(`${rawPreviousBody}\n${body}`, header)
: bodyWithHeader(body, header) : bodyWithHeader(body, header),
} },
}); });
} }
async function createComment(octokit, repo, issue_number, body, header, previousBody) { async function createComment(octokit, repo, issue_number, body, header, previousBody) {
@ -130,7 +130,7 @@ async function createComment(octokit, repo, issue_number, body, header, previous
return await octokit.rest.issues.createComment({ return await octokit.rest.issues.createComment({
...repo, ...repo,
issue_number, issue_number,
body: previousBody ? `${previousBody}\n${body}` : bodyWithHeader(body, header) body: previousBody ? `${previousBody}\n${body}` : bodyWithHeader(body, header),
}); });
} }
async function deleteComment(octokit, id) { async function deleteComment(octokit, id) {
@ -218,46 +218,46 @@ exports.repo = buildRepo();
exports.header = core.getInput("header", { required: false }); exports.header = core.getInput("header", { required: false });
exports.append = core.getBooleanInput("append", { required: true }); exports.append = core.getBooleanInput("append", { required: true });
exports.hideDetails = core.getBooleanInput("hide_details", { exports.hideDetails = core.getBooleanInput("hide_details", {
required: true required: true,
}); });
exports.recreate = core.getBooleanInput("recreate", { required: true }); exports.recreate = core.getBooleanInput("recreate", { required: true });
exports.hideAndRecreate = core.getBooleanInput("hide_and_recreate", { exports.hideAndRecreate = core.getBooleanInput("hide_and_recreate", {
required: true required: true,
}); });
exports.hideClassify = core.getInput("hide_classify", { exports.hideClassify = core.getInput("hide_classify", {
required: true required: true,
}); });
exports.deleteOldComment = core.getBooleanInput("delete", { required: true }); exports.deleteOldComment = core.getBooleanInput("delete", { required: true });
exports.onlyCreateComment = core.getBooleanInput("only_create", { exports.onlyCreateComment = core.getBooleanInput("only_create", {
required: true required: true,
}); });
exports.onlyUpdateComment = core.getBooleanInput("only_update", { exports.onlyUpdateComment = core.getBooleanInput("only_update", {
required: true required: true,
}); });
exports.skipUnchanged = core.getBooleanInput("skip_unchanged", { exports.skipUnchanged = core.getBooleanInput("skip_unchanged", {
required: true required: true,
}); });
exports.hideOldComment = core.getBooleanInput("hide", { required: true }); exports.hideOldComment = core.getBooleanInput("hide", { required: true });
exports.githubToken = core.getInput("GITHUB_TOKEN", { required: true }); exports.githubToken = core.getInput("GITHUB_TOKEN", { required: true });
exports.ignoreEmpty = core.getBooleanInput("ignore_empty", { exports.ignoreEmpty = core.getBooleanInput("ignore_empty", {
required: true required: true,
}); });
function buildRepo() { function buildRepo() {
return { return {
owner: core.getInput("owner", { required: false }) || github_1.context.repo.owner, owner: core.getInput("owner", { required: false }) || github_1.context.repo.owner,
repo: core.getInput("repo", { required: false }) || github_1.context.repo.repo repo: core.getInput("repo", { required: false }) || github_1.context.repo.repo,
}; };
} }
async function getBody() { async function getBody() {
const pathInput = core.getMultilineInput("path", { required: false }); const pathInput = core.getMultilineInput("path", { required: false });
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", { const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
required: true required: true,
}); });
if (pathInput && pathInput.length > 0) { if (pathInput && pathInput.length > 0) {
try { try {
const globber = await (0, glob_1.create)(pathInput.join("\n"), { const globber = await (0, glob_1.create)(pathInput.join("\n"), {
followSymbolicLinks, followSymbolicLinks,
matchDirectories: false matchDirectories: false,
}); });
return (await globber.glob()).map(path => (0, node_fs_1.readFileSync)(path, "utf-8")).join("\n"); return (await globber.glob()).map(path => (0, node_fs_1.readFileSync)(path, "utf-8")).join("\n");
} }

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

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

View file

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

View file

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