Skip to content

Commit f621e15

Browse files
authored
Merge pull request #480 from mkobayashime/oxlint
Migrate lint and format from ESLint + Biome to Oxlint + Oxfmt
2 parents 18d185d + 5cf9f2c commit f621e15

38 files changed

Lines changed: 287 additions & 489 deletions

.cspell.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
{
2-
"words": [
3-
"userscript",
4-
"userscripts",
5-
"bundlemonkey",
6-
"docgen",
7-
"tampermonkey"
8-
]
2+
"words": ["userscript", "userscripts", "bundlemonkey", "docgen", "tampermonkey"]
93
}

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ userscript に書かれた処理は基本的に全て他者の Web アプリケ
3030

3131
- 特に `warn`/`error` で出力するのは避ける
3232
- 完成後にログを出す処理は原則的に残さない
33-
- つまり例外の発生時はエラーを出さず、サイレントに終了する
34-
- 失敗したことにユーザーが気づけることが重要な場合は `window.alert` などを活用する
33+
- つまり例外の発生時はエラーを出さず、サイレントに終了する
34+
- 失敗したことにユーザーが気づけることが重要な場合は `window.alert` などを活用する
3535
- 実装中に挙動を確認したり値を知りたいなど、開発中に必要な場合は許容

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
bundlemonkey = bunx --bun bundlemonkey
2+
oxlint = bunx oxlint
3+
oxfmt = bunx oxfmt
24
biome = bunx biome
3-
eslint = bunx eslint
45

56
node_modules: PHONY
67
ifeq ($(CI), true)
@@ -10,16 +11,18 @@ else
1011
endif
1112

1213
lint: node_modules PHONY
14+
$(oxfmt) --check
15+
$(oxlint) --type-aware
1316
$(biome) check .
14-
$(eslint) .
1517

1618
lint.fix: node_modules PHONY
19+
$(oxfmt)
20+
$(oxlint) --fix --type-aware
1721
$(biome) check --fix .
18-
$(eslint) --fix .
1922

2023
lint.fix.dist: node_modules PHONY
21-
$(biome) check --config-path ./biome-dist.json --fix dist
22-
$(eslint) --fix dist
24+
$(oxfmt) dist
25+
$(oxlint) -c oxlint.dist.config.ts --fix dist
2326

2427
dev: dev.remote PHONY
2528

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ Display Slack emoji with white background and in a slightly larger size
112112

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

115-
Mirrored video in YouTube
115+
Mirrored video in YouTube

bin/docgen.ts

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,11 @@ const getFiles = async (): Promise<{
1919
return {
2020
scripts: await Array.fromAsync(
2121
new Glob(
22-
path.resolve(
23-
import.meta.dirname,
24-
"..",
25-
"src",
26-
"userscripts",
27-
"*",
28-
"index.user.ts",
29-
),
22+
path.resolve(import.meta.dirname, "..", "src", "userscripts", "*", "index.user.ts"),
3023
).scan(),
3124
),
3225
styles: await Array.fromAsync(
33-
new Glob(
34-
path.resolve(import.meta.dirname, "..", "src", "*.user.css"),
35-
).scan(),
26+
new Glob(path.resolve(import.meta.dirname, "..", "src", "*.user.css")).scan(),
3627
),
3728
};
3829
} catch (err) {
@@ -50,31 +41,21 @@ const parseUserStyleComment = async ({
5041
const file = await readFile(filepath);
5142
const lines = file.toString().split("\n");
5243

53-
if (
54-
lines.length === 0 ||
55-
lines.some((line) => line.includes("docgen-ignore"))
56-
)
57-
return null;
44+
if (lines.length === 0 || lines.some((line) => line.includes("docgen-ignore"))) return null;
5845

5946
const commentPrefix = {
6047
title: "@name",
6148
description: "@description",
6249
};
6350

64-
const titleLine = lines.find((line) =>
65-
line.startsWith(commentPrefix.title),
66-
);
67-
const descriptionLine = lines.find((line) =>
68-
line.startsWith(commentPrefix.description),
69-
);
51+
const titleLine = lines.find((line) => line.startsWith(commentPrefix.title));
52+
const descriptionLine = lines.find((line) => line.startsWith(commentPrefix.description));
7053

7154
if (titleLine === undefined) return null;
7255
return {
7356
filename: path.basename(filepath),
7457
title: titleLine.slice(commentPrefix.title.length).trim(),
75-
description: descriptionLine
76-
?.slice(commentPrefix.description.length)
77-
.trim(),
58+
description: descriptionLine?.slice(commentPrefix.description.length).trim(),
7859
};
7960
} catch (err) {
8061
console.error(err);
@@ -89,11 +70,7 @@ const userscriptSourceSchema = v.object({
8970
}),
9071
});
9172

92-
const getUserScriptProperties = async ({
93-
files,
94-
}: {
95-
files: string[];
96-
}): Promise<FileProperties[]> =>
73+
const getUserScriptProperties = async ({ files }: { files: string[] }): Promise<FileProperties[]> =>
9774
(
9875
await Promise.all(
9976
files.map(async (filepath) => {
@@ -112,11 +89,7 @@ const getUserScriptProperties = async ({
11289
.filter((s) => s !== undefined)
11390
.sort((a, b) => (a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1));
11491

115-
const getUserStyleProperties = async ({
116-
files,
117-
}: {
118-
files: string[];
119-
}): Promise<FileProperties[]> =>
92+
const getUserStyleProperties = async ({ files }: { files: string[] }): Promise<FileProperties[]> =>
12093
(
12194
await Promise.all(
12295
files.map(async (file) => {
@@ -147,10 +120,7 @@ const updateReadme = async (scriptsMarkdown: string): Promise<void> => {
147120
if (!readme) return;
148121

149122
const readmeKeyword = "<!-- docgen -->";
150-
const readmeCommonPart = readme.slice(
151-
0,
152-
readme.indexOf(readmeKeyword) + readmeKeyword.length,
153-
);
123+
const readmeCommonPart = readme.slice(0, readme.indexOf(readmeKeyword) + readmeKeyword.length);
154124

155125
const updatedReadme = `${readmeCommonPart}\n\n${scriptsMarkdown}`;
156126
await writeFile(path.resolve("README.md"), updatedReadme);
@@ -176,9 +146,7 @@ void (async () => {
176146
)
177147
.join("\n\n");
178148
const stylesMarkdown = styleFileProperties
179-
.map((fileProperties) =>
180-
generateMdFileEntry({ ...fileProperties, fileKind: "style" }),
181-
)
149+
.map((fileProperties) => generateMdFileEntry({ ...fileProperties, fileKind: "style" }))
182150
.join("\n\n");
183151

184152
const joinedMarkdown = [

biome-dist.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

biome.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3-
"extends": ["@mkobayashime/shared-config/biome"],
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
48
"files": {
5-
"includes": ["**", "!**/dist"]
9+
"includes": ["**/*.css"]
610
},
711
"formatter": {
812
"indentStyle": "space",

0 commit comments

Comments
 (0)