Skip to content

Commit

Permalink
ESLint autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobayashime committed Sep 30, 2024
1 parent 29b125b commit 5414e60
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 18 deletions.
2 changes: 2 additions & 0 deletions bin/dev.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import path from "node:path";

import * as rollup from "rollup";
import typescript from "@rollup/plugin-typescript";
import chokidar from "chokidar";
import chalk from "chalk";

import { copyToClipboardPlugin } from "../copyToClipboardRollupPlugin.js";
import { userscriptMetaPlugin } from "../src/userscripts/meta/rollupPlugin.js";

Expand Down
3 changes: 2 additions & 1 deletion bin/docgen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from "path";
import { readFile, writeFile } from "fs/promises";

import { pipe } from "fp-ts/lib/function.js";
import * as O from "fp-ts/lib/Option.js";
import * as A from "fp-ts/lib/Array.js";
Expand Down Expand Up @@ -145,7 +146,7 @@ const updateReadme = async (scriptsMarkdown: string): Promise<void> => {
readme.indexOf(readmeKeyword) + readmeKeyword.length,
);

const updatedReadme = readmeCommonPart + "\n\n" + scriptsMarkdown;
const updatedReadme = `${readmeCommonPart}\n\n${scriptsMarkdown}`;
await writeFile(path.resolve("README.md"), updatedReadme);
};

Expand Down
1 change: 1 addition & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import typescript from "@rollup/plugin-typescript";
import { globSync } from "glob";
import { RollupOptions } from "rollup";

import { userscriptMetaPlugin } from "./src/userscripts/meta/rollupPlugin";

const tsScripts = globSync("./src/userscripts/*.user.ts");
Expand Down
1 change: 0 additions & 1 deletion src/userscripts/github-pr-submission-shortcuts.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ void (() => {
);
if (automergeConfirmButton) {
automergeConfirmButton.click();
return;
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config: { GOOGLE_ACCOUNT_ADDRESSES: string[] } = {
const xUserEmailElement = document.getElementById("xUserEmail");
if (!xUserEmailElement) return;

if (!GOOGLE_ACCOUNT_ADDRESSES.includes(xUserEmailElement?.innerText)) {
if (!GOOGLE_ACCOUNT_ADDRESSES.includes(xUserEmailElement.innerText)) {
window.alert(`Unintended account detected: ${xUserEmailElement.innerText}`);
}
})(config);
Expand Down
1 change: 1 addition & 0 deletions src/userscripts/meta/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "path";

import { globSync } from "glob";

import { meta } from "./index.js";
Expand Down
2 changes: 1 addition & 1 deletion src/userscripts/meta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type UserScriptMeta = {
docgenIgnore?: boolean;
};

export const meta: { [name: string]: UserScriptMeta | undefined } = {
export const meta: Record<string, UserScriptMeta | undefined> = {
"copy-lyrics": {
description: "Copy lyrics automatically in supported sites",
match: [
Expand Down
3 changes: 2 additions & 1 deletion src/userscripts/meta/rollupPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "path";

import { Plugin } from "rollup";

import { meta, UserScriptMeta } from "./index.js";
Expand All @@ -12,7 +13,7 @@ export const userscriptMetaPlugin = (): Plugin => ({
throw new Error(`Meta not found for userscript: ${chunk.fileName}`);
}

return generateHeader(scriptMeta, chunk.fileName) + "\n\n" + code;
return `${generateHeader(scriptMeta, chunk.fileName)}\n\n${code}`;
},
});

Expand Down
1 change: 0 additions & 1 deletion src/userscripts/pinterest-save-from-site-shortcuts.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
);
if (dropdownSaveButton) {
dropdownSaveButton.click();
return;
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/userscripts/scrapbox-force-theme.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* 有効化するプロジェクトの id またはマッチする RegExp. 空配列の場合全プロジェクトで有効.
* @type Array<string | RegExp>
*/
const enabledProjectIds: Array<string | RegExp> = [];
const enabledProjectIds: (string | RegExp)[] = [];

const isProjectEnabled = (projectId: string) => {
if (enabledProjectIds.length === 0) return true;
Expand All @@ -34,8 +34,8 @@
const url = window.location.href;

if (!settingPagesPattern.test(url)) {
const projectId = window.location.href.match(
RegExp("^https://scrapbox.io/(?<projectId>.*)/.*$"),
const projectId = RegExp("^https://scrapbox.io/(?<projectId>.*)/.*$").exec(
window.location.href,
)?.groups?.projectId;

if (!projectId) return;
Expand Down
10 changes: 5 additions & 5 deletions src/userscripts/scrapbox-no-project-styles.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* このスクリプトを有効化するプロジェクトの id またはマッチする RegExp. 空配列の場合全プロジェクトで有効.
* @type Array<string | RegExp>
*/
const enabledProjectIds: Array<string | RegExp> = [];
const enabledProjectIds: (string | RegExp)[] = [];

/**
* このスクリプトを無効化するプロジェクトの id またはマッチする RegExp. `enabledProjectIds` を上書きします.
* @type Array<string | RegExp>
*/
const disabledProjectIds: Array<string | RegExp> = [];
const disabledProjectIds: (string | RegExp)[] = [];

const isProjectEnabled = (projectId: string) => {
if (
Expand Down Expand Up @@ -40,9 +40,9 @@
const url = window.location.href;

if (!settingPagesPattern.test(url)) {
const projectId = window.location.href.match(
RegExp("^https://scrapbox.io/(?<projectId>.*)/.*$"),
)?.groups?.projectId;
const projectId = RegExp(
"^https://scrapbox.io/(?<projectId>.*)/.*$",
).exec(window.location.href)?.groups?.projectId;

if (!projectId) return;

Expand Down
9 changes: 5 additions & 4 deletions src/userscripts/twitter-shortcuts.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isTyping } from "./utils/isTyping";
const config = {};

const findTweetInCenter = () => {
if (window.location.href.match(RegExp("^https://twitter.com/.*/status/"))) {
if (RegExp("^https://twitter.com/.*/status/").exec(window.location.href)) {
return document.querySelector<HTMLElement>(
"article[data-testid='tweet'][tabindex='-1']",
);
Expand Down Expand Up @@ -79,9 +79,10 @@ const findTweetInCenter = () => {
}

if (e.ctrlKey && e.key === "e") {
const tweetURLMatch = window.location.href.match(
/^https:\/\/twitter\.com\/\S+\/status\/\d+[^/]*/,
);
const tweetURLMatch =
/^https:\/\/twitter\.com\/\S+\/status\/\d+[^/]*/.exec(
window.location.href,
);
if (!tweetURLMatch) return;

e.preventDefault();
Expand Down

0 comments on commit 5414e60

Please sign in to comment.