Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"words": [
"userscript",
"userscripts",
"bundlemonkey",
"docgen",
"tampermonkey"
]
"words": ["userscript", "userscripts", "bundlemonkey", "docgen", "tampermonkey"]
}
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ userscript に書かれた処理は基本的に全て他者の Web アプリケ

- 特に `warn`/`error` で出力するのは避ける
- 完成後にログを出す処理は原則的に残さない
- つまり例外の発生時はエラーを出さず、サイレントに終了する
- 失敗したことにユーザーが気づけることが重要な場合は `window.alert` などを活用する
- つまり例外の発生時はエラーを出さず、サイレントに終了する
- 失敗したことにユーザーが気づけることが重要な場合は `window.alert` などを活用する
- 実装中に挙動を確認したり値を知りたいなど、開発中に必要な場合は許容
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bundlemonkey = bunx --bun bundlemonkey
oxlint = bunx oxlint
oxfmt = bunx oxfmt
biome = bunx biome
eslint = bunx eslint

node_modules: PHONY
ifeq ($(CI), true)
Expand All @@ -10,16 +11,18 @@ else
endif

lint: node_modules PHONY
$(oxfmt) --check
$(oxlint) --type-aware
$(biome) check .
$(eslint) .

lint.fix: node_modules PHONY
$(oxfmt)
$(oxlint) --fix --type-aware
$(biome) check --fix .
$(eslint) --fix .

lint.fix.dist: node_modules PHONY
$(biome) check --config-path ./biome-dist.json --fix dist
$(eslint) --fix dist
$(oxfmt) dist
$(oxlint) -c oxlint.dist.config.ts --fix dist

dev: dev.remote PHONY

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ Display Slack emoji with white background and in a slightly larger size

### [YouTube - Mirrored video](https://github.com/mkobayashime/userscripts/raw/main/src/youtube-mirrored.user.css)

Mirrored video in YouTube
Mirrored video in YouTube
52 changes: 10 additions & 42 deletions bin/docgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,11 @@ const getFiles = async (): Promise<{
return {
scripts: await Array.fromAsync(
new Glob(
path.resolve(
import.meta.dirname,
"..",
"src",
"userscripts",
"*",
"index.user.ts",
),
path.resolve(import.meta.dirname, "..", "src", "userscripts", "*", "index.user.ts"),
).scan(),
),
styles: await Array.fromAsync(
new Glob(
path.resolve(import.meta.dirname, "..", "src", "*.user.css"),
).scan(),
new Glob(path.resolve(import.meta.dirname, "..", "src", "*.user.css")).scan(),
),
};
} catch (err) {
Expand All @@ -50,31 +41,21 @@ const parseUserStyleComment = async ({
const file = await readFile(filepath);
const lines = file.toString().split("\n");

if (
lines.length === 0 ||
lines.some((line) => line.includes("docgen-ignore"))
)
return null;
if (lines.length === 0 || lines.some((line) => line.includes("docgen-ignore"))) return null;

const commentPrefix = {
title: "@name",
description: "@description",
};

const titleLine = lines.find((line) =>
line.startsWith(commentPrefix.title),
);
const descriptionLine = lines.find((line) =>
line.startsWith(commentPrefix.description),
);
const titleLine = lines.find((line) => line.startsWith(commentPrefix.title));
const descriptionLine = lines.find((line) => line.startsWith(commentPrefix.description));

if (titleLine === undefined) return null;
return {
filename: path.basename(filepath),
title: titleLine.slice(commentPrefix.title.length).trim(),
description: descriptionLine
?.slice(commentPrefix.description.length)
.trim(),
description: descriptionLine?.slice(commentPrefix.description.length).trim(),
};
} catch (err) {
console.error(err);
Expand All @@ -89,11 +70,7 @@ const userscriptSourceSchema = v.object({
}),
});

const getUserScriptProperties = async ({
files,
}: {
files: string[];
}): Promise<FileProperties[]> =>
const getUserScriptProperties = async ({ files }: { files: string[] }): Promise<FileProperties[]> =>
(
await Promise.all(
files.map(async (filepath) => {
Expand All @@ -112,11 +89,7 @@ const getUserScriptProperties = async ({
.filter((s) => s !== undefined)
.sort((a, b) => (a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1));

const getUserStyleProperties = async ({
files,
}: {
files: string[];
}): Promise<FileProperties[]> =>
const getUserStyleProperties = async ({ files }: { files: string[] }): Promise<FileProperties[]> =>
(
await Promise.all(
files.map(async (file) => {
Expand Down Expand Up @@ -147,10 +120,7 @@ const updateReadme = async (scriptsMarkdown: string): Promise<void> => {
if (!readme) return;

const readmeKeyword = "<!-- docgen -->";
const readmeCommonPart = readme.slice(
0,
readme.indexOf(readmeKeyword) + readmeKeyword.length,
);
const readmeCommonPart = readme.slice(0, readme.indexOf(readmeKeyword) + readmeKeyword.length);

const updatedReadme = `${readmeCommonPart}\n\n${scriptsMarkdown}`;
await writeFile(path.resolve("README.md"), updatedReadme);
Expand All @@ -176,9 +146,7 @@ void (async () => {
)
.join("\n\n");
const stylesMarkdown = styleFileProperties
.map((fileProperties) =>
generateMdFileEntry({ ...fileProperties, fileKind: "style" }),
)
.map((fileProperties) => generateMdFileEntry({ ...fileProperties, fileKind: "style" }))
.join("\n\n");

const joinedMarkdown = [
Expand Down
11 changes: 0 additions & 11 deletions biome-dist.json

This file was deleted.

8 changes: 6 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@mkobayashime/shared-config/biome"],
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!**/dist"]
"includes": ["**/*.css"]
},
"formatter": {
"indentStyle": "space",
Expand Down
Loading